enezhadian
enezhadian

Reputation: 946

Getting ProcessInfo for NSRunningApplication

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 ProcessInfos for NSRunningApplications? Unfortunately I couldn't find anything in Apple Developer Documentation.

Upvotes: 1

Views: 1022

Answers (1)

Charles Srstka
Charles Srstka

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

Related Questions