Process list on Linux via Python
linux, python
Solution
IMO looking at the `/proc` filesystem is less nasty than hacking the text output of `ps`.
import os
pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
for pid in pids:
try:
print open(os.path.join('/proc', pid, 'cmdline'), 'rb').read().split('\0')
except IOError: # proc has already terminated
continue
Problem
How can I get running process list using Python on Linux?