Getting a list of processes (just like ps aux) that plays well with Sandbox

I am building a Mac OS app that needs to periodically grab the list of running processes. My first appraoch was to use NSTask which basicallly just executes 'ps aux'. However, after enabling app sandboxing, this broke because apparently I can't run '/bin/ps' in sandbox. I then tried listing out all running applications using 'NSWorkspace.sharedWorkspace().runningApplications' and I found that this only list user applications.

I am wondering if you guys know a way to get a list of running processes of all users (root included) that plays nicely with App Sandbox and will be approved by MAS.


If root access is required for this kind of thing, is it possible to ask for root privlege with app sandbox enabled?

I am wondering if you guys know a way to get a list of running processes of all users (root included) …

The standard techniques for this include:

I don’t know whether these work within the App Sandbox, but it’d be easy enough for you to test them.

If root access is required for this kind of thing, is it possible to ask for root privlege with app sandbox enabled?

That’s specifically not allowed per the App Store Review Guidelines

Taking a step back, I want to offer a word of caution here: in general App Store apps, both on the Mac and other platforms, work best when they work as apps (separate, independent, user-visible items) rather than trying to

  • interact with other, unrelated apps, or

  • replicate system functionality

In my experience, folks that ask about getting a full process list will generally run into other sandbox restrictions because the sandbox is doing it’s best to force apps to act as apps. If getting a process list is central to your app’s functionality, you may want to rethink you product or your deployment strategy.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Getting a list of processes (just like ps aux) that plays well with Sandbox
 
 
Q