code: def _reap_child(self):
          
          if self.detached and self.child_is_immediate_subprocess:
              LOG.debug('%r: immediate child is detached, won\'t reap it', self)
              return
  
          if self.profiling:
              LOG.info('%r: wont kill child because profiling=True', self)
              return
  
          if self._reaped:
              # on_disconnect() may be invoked more than once, for example, if
              # there is still a pending message to be sent after the first
              # on_disconnect() call.
              return
  
          try:
              pid, status = os.waitpid(self.pid, os.WNOHANG)
          except OSError:
              e = sys.exc_info()[1]
              if e.args[0] == errno.ECHILD:
                  LOG.warn('%r: waitpid(%r) produced ECHILD', self, self.pid)
                  return
              raise
  
          self._reaped = True
          if pid:
              LOG.debug('%r: PID %d %s', self, pid, wstatus_to_str(status))
              return
  
          if not self._router.profiling:
              # For processes like sudo we cannot actually send sudo a signal,
              # because it is setuid, so this is best-effort only.
              LOG.debug('%r: child process still alive, sending SIGTERM', self)
              try:
                  os.kill(self.pid, signal.SIGTERM)
              except OSError:
                  e = sys.exc_info()[1]
                  if e.args[0] != errno.EPERM:
                      raise
docs: Reap the child process during disconnection.