Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective C code for background processes

I have used NSApplication and NSWorkspace to get a list of running applications.

But it is only giving me the applications that are active from the administrator and not the root processes that run in the background.

I want to get a list of all running processes and keep updating that list as soon as a new process spawns.

I prefer not to use NSTask and parsing the output.

Is there a fix for this?

NSArray * runningapps = [[NSWorkspace sharedWorkspace] runningApplications];
like image 859
Bharath Suresh Avatar asked Oct 17 '22 17:10

Bharath Suresh


2 Answers

Refer to the website given below : https://github.com/objective-see/ProcInfo

like image 113
Great Person Avatar answered Oct 21 '22 08:10

Great Person


To have access to the list of root processes you need to do stuff very similar to what the ps command does. If you want to go at it, go study the source code of this tool:

https://opensource.apple.com/source/adv_cmds/adv_cmds-172/ps/

However, as you can see, this is not easy. Thus, if you don't want to reinvent the wheel, I'd just parse the output of ps command with grep or you will need to write your own code to do what you want.

like image 22
jvarela Avatar answered Oct 21 '22 07:10

jvarela