1

I have a cocoa app that needs to get a list of processes. After enabling app sandboxing, I get /bin/ps: Operation not permitted. Is there another way of doing this that's compatible with app sandboxing? I am running this via NSTask

denniss
  • 17,229
  • 26
  • 92
  • 141

2 Answers2

1

You can't run ps from the sandbox, because it is a set-uid root program.

There is no other documented way to get a process list. There is, however, an undocumented API described in libproc.h. I'm not sure if you can use it from the sandbox, but it's worth a try.

tbodt
  • 16,609
  • 6
  • 58
  • 83
1

You can use [[NSWorkspace sharedWorkspace] runningApplications] to get a list of all processes. This will return an array of NSRunningApplications.

https://developer.apple.com/reference/appkit/nsworkspace https://developer.apple.com/reference/appkit/nsworkspace/1534059-runningapplications https://developer.apple.com/reference/appkit/nsrunningapplication

mahal tertin
  • 3,239
  • 24
  • 41