3

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

//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,“无效参数”。终止临时进程。

谁能帮我解决这个问题?

4

0 回答 0