在Sandbox中调用系统工具的问题

来源:互联网 发布:海思科技人工智能 编辑:程序博客网 时间:2024/05/21 10:02


在sandbox中要调用system的工具,用system函数,NSTask方式有的成功,有的不成功。

成功的例子有:

/usr/sbin/screencapture

/usr/bin/stat

不成功的例子有:

/usr/bin/qlmanage

/usr/bin/shasum

/usr/bin/hexdump

/sbin/ping


在网上找到一下答案

Sandbox and running /usr/bin/purge using system()

in an app that is on the Mac App Store, I was doing the following:

system("/usr/bin/nice -n 20 /usr/bin/purge &> /dev/null &");

This worked fine, but now I'm trying to submit a new version, and they're forcing me to enable the Sandbox. However, with the sandbox, that call fails, giving messages like this in the Console:

7/20/13 12:58:59.000 AM kernel[0]: Sandbox: sh(28537) deny file-read-data /dev/ttys0007/20/13 12:58:59.968 AM purge[28538]: bootstrap_look_up(): Permission denied7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny mach-lookup com.apple.appleprofilepolicyd7/20/13 12:59:00.521 AM purge[28538]: <CPDevice.m:3813> Unable to create new counter client.7/20/13 12:59:00.523 AM purge[28538]: <CPOSX.m:1188>    Unable to get user client so as to poke the kernel.7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny iokit-open ApplePerformanceCounterManagerUserClient7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny iokit-open AppleProfileUtilitiesUserClient7/20/13 12:59:00.000 AM kernel[0]: AppleProfileUtilitiesUserClient: bad busy count (0,-1)7/20/13 12:59:00.000 AM kernel[0]: Backtrace 0xffffff802d22d4d2 0xffffff802d231fc9 0xffffff802ceb3137 0 0 0 0

Is there any way to work around this?

share|improve this question
 

1 Answer

activeoldestvotes
up vote0down vote

The official word on NSTask and Sandboxing is 'some executables may work.' For me this translates to 'don't count on it'. There are a ton of questions in the currently down Apple Dev Forums about this and purge definitely seems to be one that is blacklisted.


0 0
原创粉丝点击