I have an XPC service, running as root, that is required to monitor if other specific processes are running.
Retrieving the list of running processes from NSWorkspace only seems to produce the list of user processes and no root-owned daemons
let workspace = NSWorkspace.shared
let applications = workspace.runningApplications
for application in applications {
if let url = (application.executableURL?.absoluteString) {
os_log("%{public}s", log:scribe, type:.debug, url)
}
}
}
How would you retrieve the complete set of running processes, including daemons?
Of-course, it could execute ps
and parse the output, but that's not ideal to be calling frequently.