CMS 3D CMS Logo

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