使用nstask与沙箱时应用程序崩溃

时间:2013-07-21 10:40:59

标签: sandbox nstask

我在我的应用中使用了这段代码:

//create task
NSTask * task=[[NSTask alloc] init];
[task setLaunchPath:@"/bin/ps"];
NSArray * arguments = [NSArray arrayWithObjects: @"axco command,pcpu",nil];
[task setArguments:arguments];

NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];

NSFileHandle *file = [pipe fileHandleForReading];
[task launch];

当我禁用沙箱时,它可以正常工作。但是,如果我启用了沙盒,它会因此异常而崩溃:

  

NSTask:路径'/ bin / ps'的任务创建失败:22,“无效参数”。终止临时过程。

有人可以帮我解决这个问题吗?

0 个答案:

没有答案