Go to the documentation of this file.00001 import os,sys,os.path,shlex
00002 from subprocess import Popen,PIPE,STDOUT
00003 from cStringIO import StringIO
00004
00005 def runCmmd(cmmdline,shell=False):
00006 """runsubprocess return processid
00007 """
00008 args=[]
00009 proc=Popen(cmmdline,shell=shell,stdout=PIPE,stdin=PIPE,stderr=STDOUT)
00010 stdout_value,stderr_value=proc.communicate()
00011 print repr(stdout_value)
00012 return proc.pid
00013
00014 def processRunning(processid):
00015 """
00016 check if a process is still running
00017 """
00018 return os.path.exists(os.path.join('/proc',str(processid)))
00019
00020 if __name__=='__main__':
00021 print processRunning(13378)
00022 pid= runCmmd('cat -; echo ";to stderr" 1>&2',shell=True)
00023 print processRunning(pid)