Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the full list of running processes on a Mac from a python app

I want to get the list of running processes on the Mac, similar to what you get from 'ps -ea'

I have tried os.popen('ps -ea') but this only lists a small subset of the processes, presumably those owned by the owning shell.

Other options I have tried are

'sh -c /bin/ps -ea'
'bash -c /bin/ps -ea'
'csh -c /bin/ps -ea'
Running as root via sudo
data = subprocess.Popen(['ps','ea'], stdout=subprocess.PIPE).stdout.readlines()

What other methods are there that might give me the full process information listing?

This is for a wx python app to monitor specific processes and spot when they die.

like image 660
David Sykes Avatar asked Dec 19 '25 08:12

David Sykes


1 Answers

os.popen('ps aux') looks like it's listing all processes for me.

like image 96
Mike Akers Avatar answered Dec 21 '25 21:12

Mike Akers



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!