Created
October 15, 2012 17:46
-
-
Save orospakr/3893949 to your computer and use it in GitHub Desktop.
Python implementation of quick and dirty ps for QNX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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