def safe_kill(pid, signum):
  """Kill a process with the specified signal, catching nonfatal errors."""
  assert(isinstance(pid, IntegerForPid))
  assert(isinstance(signum, int))
  try:
    os.kill(pid, signum)
  except (IOError, OSError) as e:
    if e.errno in [errno.ESRCH, errno.EPERM]:
      pass
    elif e.errno == errno.EINVAL:
      raise ValueError("Invalid signal number {}: {}"
                       .format(signum, e),
                       e)
    else:
      raise
def safe_kill ( pid , signum ) : assert ( isinstance ( pid , IntegerForPid ) ) assert ( isinstance ( signum , int ) ) try : os . kill ( pid , signum ) except ( IOError , OSError ) as e : if e . errno in [ errno . ESRCH , errno . EPERM ] : pass elif e . errno == errno . EINVAL : raise ValueError ( "Invalid signal number {}: {}" . format ( signum , e ) , e ) else : raise
Kill a process with the specified signal, catching nonfatal errors.