Take the 2-minute tour ×

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.

share|improve this question
you can try the subprocess module if your Python version is 2.4++. just curious, why do you want to do this in Python.? –  ghostdog74 Nov 4 '09 at 13:55
I do get the same output when calling ps -ea from the terminal or using os.popen('ps -ea'). Are you sure you're reading the file object completely ? –  Jean Regisser Nov 4 '09 at 14:13
os.popen('ps aux') gives me the full list, os.popen('ps ea') gives me a minimal list, so I'm pretty sure I am –  David Sykes Nov 4 '09 at 14:22

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
and it does for me too! Thanks. –  David Sykes Nov 4 '09 at 14:18
Try using subprocess.Popen -- it's the preferred approach. –  S.Lott Nov 4 '09 at 14:32
data = subprocess.Popen(['ps','aux'], stdout=subprocess.PIPE).stdout.readlines() works just as well –  David Sykes Nov 4 '09 at 14:50

Your Answer


