<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def proc_exit(self, details):
 """ Handle the event when one of the task processes exits. """

        log = self._params.get('log', self._discard)
        pid = self._key
        exit_code = details
        why = statusfmt(exit_code)
        proc = None
        for p in self._parent._proc_state:
            if pid == p.pid:
                proc = p
        if proc is None:
            log.error("Legion reported exit of unknown pid %s for task %r which %s", pid, self._name, why)
            return

        now = time.time()
        proc.pid = None
        proc.exit_code = exit_code
        proc.exited = now
        proc.pending_sig = None
        proc.next_sig = None
        self._parent._last_status = exit_code
        extant = len(self._parent.get_pids())
        if extant == 0:
            self._parent._started = None
            self._parent._stopping = None
            self._parent._stopped = now
            self._parent.onexit()
        else:
            log.debug("Task '%s' still has %d process%s running", self._name, extant, ses(extant, 'es'))
        if exit_code and not self._parent._terminated:
            log.warning("Task '%s' pid %d %s -- unexpected error exit", self._name, pid, why)
        else:
            log.info("Task '%s' pid %d %s", self._name, pid, why)