Index: twisted/internet/test/test_process.py =================================================================== --- twisted/internet/test/test_process.py (revision 31396) +++ twisted/internet/test/test_process.py (working copy) @@ -599,6 +599,15 @@ +class FakeFile(object): + """ + A fake file object which pretends it can be closed. + """ + def close(self): + pass + + + class FakeResourceModule(object): """ Fake version of L{resource} which hard-codes a particular rlimit for maximum @@ -682,8 +691,14 @@ """ This is a mock for L{open}. It just keeps track of the fact that a file has opened so an extra file descriptor is found in /dev/fd. + + It also returns a L{FakeFile} which can be "closed". It would be more + realistic to make the FD list shrink when the file is "fake closed" but + it's not necessary for the detection algorithm we currently have in + process.py. """ self.openedFile = True + return FakeFile() def saveResourceModule(self): Index: twisted/internet/process.py =================================================================== --- twisted/internet/process.py (revision 31396) +++ twisted/internet/process.py (working copy) @@ -530,6 +530,7 @@ start = self.listdir("/dev/fd") fp = self.openfile("/dev/null", "r") end = self.listdir("/dev/fd") + fp.close() return start != end