Skip to content

Instantly share code, notes, and snippets.

@orospakr
Created October 15, 2012 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orospakr/3893949 to your computer and use it in GitHub Desktop.
Save orospakr/3893949 to your computer and use it in GitHub Desktop.
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