'If, before the reactor is started with L{IReactorCore.run}, a
process is started with L{IReactorProcess.spawnProcess} and
terminates, the process is reaped once the reactor is started.'

def test_spawnProcessEarlyIsReaped(self):

    reactor = self.buildReactor()
    if self.usePTY:
        childFDs = None
    else:
        childFDs = {}
    signaled = threading.Event()
    def handler(*args):
        signaled.set()
    signal.signal(signal.SIGCHLD, handler)
    ended = Deferred()
    reactor.spawnProcess(_ShutdownCallbackProcessProtocol(ended), pyExe, [pyExe, '-c', ''], usePTY=self.usePTY, childFDs=childFDs)
    signaled.wait(120)
    if (not signaled.isSet()):
        self.fail('Timed    out    waiting    for    child    process    to    exit.')
    result = []
    ended.addCallback(result.append)
    if result:
        return
    ended.addCallback((lambda ignored: reactor.stop()))
    self.runReactor(reactor)
    self.assertTrue(result)
