'L{IProcessProtocol.childConnectionLost} is called each time a file
descriptor associated with a child process is closed.'

def test_childConnectionLost(self):

    connected = Deferred()
    lost = {0: Deferred(), 1: Deferred(), 2: Deferred()}
    class Closer(ProcessProtocol, ):
        def makeConnection(self, transport):
            connected.callback(transport)
        def childConnectionLost(self, childFD):
            lost[childFD].callback(None)
    target = 'twisted.internet.test.process_loseconnection'
    reactor = self.buildReactor()
    reactor.callWhenRunning(reactor.spawnProcess, Closer(), pyExe, [pyExe, '-m', target], env=properEnv, usePTY=self.usePTY)
    def cbConnected(transport):
        transport.write('2\n')
        return lost[2].addCallback((lambda ign: transport))
    connected.addCallback(cbConnected)
    def lostSecond(transport):
        transport.write('1\n')
        return lost[1].addCallback((lambda ign: transport))
    connected.addCallback(lostSecond)
    def lostFirst(transport):
        transport.write('\n')
    connected.addCallback(lostFirst)
    connected.addErrback(err)
    def cbEnded(ignored):
        reactor.stop()
    connected.addCallback(cbEnded)
    self.runReactor(reactor)
