Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python implementation of quick and dirty ps for QNX
#!/usr/bin/env python2.7
# tweaked version of http://stackoverflow.com/questions/2703640/process-list-on-linux-via-python
import os
import os.path
pids= [pid for pid in os.listdir('/proc') if pid.isdigit()]
for pid in pids:
try:
cmdline = open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
exefile = open(os.path.join('/proc', pid, 'exefile'), 'rb').read()
print "%s - '%s' at %s" % (pid, cmdline, exefile)
except IOError as ex:
print "Process does not exist: %s because of %s" % (pid, ex)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment