def PosixShutdown():
  """Kills a posix process with os.kill."""
  dev_process = GlobalProcess()
  children = dev_process.Children()
  for term_signal in (signal.SIGTERM, signal.SIGKILL):
    for child in children:
      if child.process is None:
        continue
      if child.process.returncode is not None:
        continue
      pid = child.process.pid
      try:
        logging.debug('posix kill %d with signal %d', pid, term_signal)
        os.kill(pid, term_signal)
      except OSError, err:
        logging.error('Error encountered sending pid %d signal %d:%s\n',
                      pid, term_signal, err)
        break

    time.sleep(0.2)


  for child in children:
    if child.process is None:
      continue
    if child.process.returncode is not None:
      continue
    try:
      child.process.wait()
    except __HOLE__, e:
      if e.errno != errno.ECHILD:
        raise e
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/dev_appserver_multiprocess.py/PosixShutdown