Advertisement
Guest User

Untitled

a guest
Nov 14th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1.     def process_exists(self, procname):
  2.         ps = subprocess.Popen("ps -A", shell=True, stdout=subprocess.PIPE)
  3.         ps_pid = ps.pid
  4.         output = ps.stdout.read()
  5.         ps.stdout.close()
  6.         ps.wait()
  7.  
  8.         for line in output.split('\n'):
  9.             if line != "" and line != None:
  10.                 fields = line.split()
  11.                 pid = fields[0]
  12.                 pname = fields[3]
  13.  
  14.                 if (pname == procname):
  15.                     return True
  16.                 else:
  17.                     return True
  18.         return False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement