CMS 3D CMS Logo

sysUtil.py
Go to the documentation of this file.
1 import os,sys,os.path,shlex
2 from subprocess import Popen,PIPE,STDOUT
3 from cStringIO import StringIO
4 
5 def runCmmd(cmmdline,shell=False):
6  """runsubprocess return processid
7  """
8  args=[]
9  proc=Popen(cmmdline,shell=shell,stdout=PIPE,stdin=PIPE,stderr=STDOUT)
10  stdout_value,stderr_value=proc.communicate()
11  print repr(stdout_value)
12  return proc.pid
13 
14 def processRunning(processid):
15  """
16  check if a process is still running
17  """
18  return os.path.exists(os.path.join('/proc',str(processid)))
19 
20 if __name__=='__main__':
21  print processRunning(13378)
22  pid= runCmmd('cat -; echo ";to stderr" 1>&2',shell=True)
23  print processRunning(pid)
def runCmmd(cmmdline, shell=False)
Definition: sysUtil.py:5
def processRunning(processid)
Definition: sysUtil.py:14
#define str(s)