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



在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/ttys000
7/20/13 12:58:59.968 AM purge[28538]: bootstrap_look_up(): Permission denied
7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny mach-lookup com.apple.appleprofilepolicyd
7/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 ApplePerformanceCounterManagerUserClient
7/20/13 12:59:00.000 AM kernel[0]: Sandbox: purge(28538) deny iokit-open AppleProfileUtilitiesUserClient
7/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

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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值