On Fri, 21 Nov 2014, at 14:08, Peter Westlake wrote: > Found it! > > from twisted.internet.protocol import ClientFactory, Protocol, > ProcessProtocol from twisted.internet import reactor > > devnull = open('/dev/null').fileno() print devnull > > factory = ClientFactory() factory.protocol = Protocol > reactor.connectTCP('localhost', 'http', factory) > reactor.callWhenRunning(reactor.spawnProcess, ProcessProtocol(), > '/bin/sleep', args=['/bin/sleep', '1000'], childFDs={0: devnull, 1: > 'r', 2:'r'}) reactor.run() > > Run this, then: > > lsof -I @localhost > > will show that the child process has the socket open on FD 0. > > Now I grant that there's no need to pass /dev/null to the stdin of the > process. I should just leave 0 out of childFDs instead. But why does > this not work? lsof shows that the socket is on FD 3 in the parent > process, and the print statement shows that the FD of devnull is 3 as > well! Am I missing something obvious? > > Peter.
I *am* missing something obvious. The file opened by open() immediately goes out of scope. AAAUGH! Peter.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python