def pid_is_alive(pid):
 path = ('/proc/%s/stat' % pid)
 try:
  stat = read_one_line(path)
 except IOError:
  if (not os.path.exists(path)):
   return False
  raise
 return (stat.split()[2] != 'Z')

def pid_is_alive ( pid ) : path = ( '/proc/%s/stat' % pid ) try : stat = read_one_line ( path ) except IOError : if ( not os . path . exists ( path ) ) : return False raise return ( stat . split ( ) [ 2 ] != 'Z' )
true if process pid exists and is not yet stuck in zombie state .