'When we are told the process ended, try to notify the other side about
how the process ended using the exit-signal or exit-status requests.
Also, close the channel.'

def processEnded(self, reason=None):

    if (reason is not None):
        err = reason.value
        if (err.signal is not None):
            signame = self._getSignalName(err.signal)
            if ((getattr(os, 'WCOREDUMP', None) is not None) and os.WCOREDUMP(err.status)):
                log.msg(('exitSignal:    %s    (core    dumped)' % (signame,)))
                coreDumped = 1
            else:
                log.msg(('exitSignal:    %s' % (signame,)))
                coreDumped = 0
            self.session.conn.sendRequest(self.session, 'exit-signal', (((common.NS(networkString(signame[3:])) + chr(coreDumped)) + common.NS('')) + common.NS('')))
        elif (err.exitCode is not None):
            log.msg(('exitCode:    %r' % (err.exitCode,)))
            self.session.conn.sendRequest(self.session, 'exit-status', struct.pack('>L', err.exitCode))
    self.session.loseConnection()
