def pid_exists(pid):
 if (pid == 0):
  return True
 try:
  os.kill(pid, 0)
 except OSError as err:
  if (err.errno == errno.ESRCH):
   return False
  elif (err.errno == errno.EPERM):
   return True
  else:
   raise err
 else:
  return True

def pid_exists ( pid ) : if ( pid == 0 ) : return True try : os . kill ( pid , 0 ) except OSError as err : if ( err . errno == errno . ESRCH ) : return False elif ( err . errno == errno . EPERM ) : return True else : raise err else : return True
check for the existence of a unix pid .