fork/exec & close file descriptors

random832 at fastmail.us random832 at fastmail.us
Wed Jun 3 09:21:19 EDT 2015


On Wed, Jun 3, 2015, at 09:08, Marko Rauhamaa wrote:
> random832 at fastmail.us:
> 
> > Why does the child process need to report the error at all? The parent
> > process will find out naturally when *it* tries to close the same file
> > descriptor.
> 
> That's not how it goes.
> 
> File descriptors are reference counted in the Linux kernel. Closes are
> no-ops except for the last one that brings the reference count to zero.
> 
> If the parent should close the file before the child, no error is
> returned to the parent.

Why would the parent close it before the child? Your scenario doesn't
seem to have anything to do with how people actually use subprocesses.



More information about the Python-list mailing list