开发者

Using NSTask as root - error: "launch path not accessible"

For some reason when I'm attempting to run a task via NSTask I receive the error message: "launch path not accessible".

My app is running as root. And if I type the EXACT 开发者_运维知识库same command in terminal, it runs fine, so I'm a bit confused.

My application copies a tool, called relaunch, to NSTemporaryDirectory(). If I try to run it from here, I get "launch path not accessible". Here is the strange thing, if I manually copy the tool to my desktop, then hardcode the path in NSTask, it will execute properly. And i have 0 idea why.

Anyone know why this is occurring?

Note: Just FYI, trying to get Sparkle to work from github.

Here is the code:

@try{
[NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
}

Where

relaunchPath = @"/var/folders/zz/zzzivhrRnAmviuee+++++++++++/-Tmp-/relaunch";


Is the error message coming from your app, or from relaunch? If you haven't changed its standard error to point anywhere else, it will write to the same stderr your app does, so you could actually be launching relaunch successfully and the error message actually be coming from relaunch.

Add an @catch block after your @try to see whether the NSTask actually fails, and check pathToRelaunch.

If you have an @catch block, please edit your question to include it. If it turns out that relaunch is where the failure is happening, but pathToRelaunch looks right, please edit your question to include the relevant source code from the relaunch tool.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜