def METHOD_NAME(self, reason):
    """IProcessProtocol API"""
    # reason.value should always be a ProcessTerminated instance
    fail = reason.value
    # print('processEnded', fail)
    if fail.exitCode != 0 and fail.exitCode is not None:
        msg = 'Process exited with code "{}".'.format(fail.exitCode)
        err = RuntimeError(msg)
        self.all_done.errback(err)
        if not self.launched.called:
            self.launched.errback(err)
    else:
        self.all_done.callback(fail)
        if not self.launched.called:
            print("FIXME: _launched should have been callbacked by now.")
            self.launched.callback(self)