Reputation: 946
I am trying to build an app for MacOS in Swift to log some information about running applications. Some of the information which I would like to get are related to the corresponding processes (user, etc.), but it doesn't seem that I can get them from NSRunningApplication
. So I was wondering is there any way to get ProcessInfo
s for NSRunningApplication
s?
Unfortunately I couldn't find anything in Apple Developer Documentation.
Upvotes: 1
Views: 1022
Reputation: 17050
You need to get the PID from NSRunningApplication's processIdentifier
property, and then you can use sysctl
to get information from the PID. See this answer:
https://stackoverflow.com/a/20169895/7258538
It's in C, but it should give you the basic idea.
Upvotes: 2