'Create a child process and close one of its output descriptors using
L{IProcessTransport.closeStdout} or L{IProcessTransport.closeStderr}.
Return a L{Deferred} which fires after verifying that the descriptor was
really closed.'

def doit(self, fd):

    p = ClosingPipesProcessProtocol(True)
    self.assertFailure(p.deferred, error.ProcessTerminated)
    p.deferred.addCallback(self._endProcess, p)
    reactor.spawnProcess(p, pyExe, [pyExe, '-u', '-c', networkString(('try:    input    =    raw_input\nexcept    NameError:    pass\ninput()\nimport    sys,    os,    time\nfor    i    in    range(1000):\n                os.write(%d,    b"foo\\n")\n                time.sleep(0.01)\nsys.exit(42)\n' % (fd,)))], env=None)
    if (fd == 1):
        p.transport.closeStdout()
    elif (fd == 2):
        p.transport.closeStderr()
    else:
        raise RuntimeError
    p.transport.write('go\n')
    p.transport.closeStdin()
    return p.deferred
