'The process was reaped and we need to report and manage its state'

def finish(self, pid, sts):

    self.drain()
    (es, msg) = decode_wait_status(sts)
    now = time.time()
    self.laststop = now
    processname = self.config.name
    if (now > self.laststart):
        too_quickly = ((now - self.laststart) < self.config.startsecs)
    else:
        too_quickly = False
        self.config.options.logger.warn(("process    %r    (%s)    laststart    time    is    in    the    future,    don't    know    how    long    process    was    running    so    assuming    it    did    not    exit    too    quickly" % (self.config.name, self.pid)))
    exit_expected = (es in self.config.exitcodes)
    if self.killing:
        self.killing = False
        self.delay = 0
        self.exitstatus = es
        msg = ('stopped:    %s    (%s)' % (processname, msg))
        self._assertInState(ProcessStates.STOPPING)
        self.change_state(ProcessStates.STOPPED)
    elif too_quickly:
        self.exitstatus = None
        self.spawnerr = 'Exited    too    quickly    (process    log    may    have    details)'
        msg = ('exited:    %s    (%s)' % (processname, (msg + ';    not    expected')))
        self._assertInState(ProcessStates.STARTING)
        self.change_state(ProcessStates.BACKOFF)
    else:
        self.delay = 0
        self.backoff = 0
        self.exitstatus = es
        if (self.state == ProcessStates.STARTING):
            self.change_state(ProcessStates.RUNNING)
        self._assertInState(ProcessStates.RUNNING)
        if exit_expected:
            msg = ('exited:    %s    (%s)' % (processname, (msg + ';    expected')))
            self.change_state(ProcessStates.EXITED, expected=True)
        else:
            self.spawnerr = ('Bad    exit    code    %s' % es)
            msg = ('exited:    %s    (%s)' % (processname, (msg + ';    not    expected')))
            self.change_state(ProcessStates.EXITED, expected=False)
    self.config.options.logger.info(msg)
    self.pid = 0
    self.config.options.close_parent_pipes(self.pipes)
    self.pipes = {}
    self.dispatchers = {}
    if (self.event is not None):
        events.notify(events.EventRejectedEvent(self, self.event))
        self.event = None
