I have a C++ application that uses libproc to get a list of open applications. Works as expected when not sandboxed. However to deploy to app store, it must be sandboxed and when doing so, proc_listallpids (from libproc) no longer works. Anyway around this?
#include <libproc.h>
#include <stdio.h>
#include <string.h>
void find_pids()
{
pid_t pids[2048];
int bytes = proc_listallpids(pids, sizeof(pids));
int n_proc = bytes / sizeof(pids[0]);
for (int i = 0; i < n_proc; i++) {
struct proc_bsdinfo proc;
int st = proc_pidinfo(pids[i], PROC_PIDTBSDINFO, 0,
&proc, PROC_PIDTBSDINFO_SIZE);
printf("%s\n", proc.pbi_name);
}
}
int main()
{
find_pids();
return 0;
}
NSWorkspace.runningApplications is the more Mac-specific way to get info about running applications (rather than just processes), it's possible that will work in a sandboxed app. But in general, sandboxed apps shouldn't be able to see each other.