fork/exec & close file descriptors

Marko Rauhamaa marko at pacujo.net
Wed Jun 3 09:08:44 EDT 2015


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.


Marko



More information about the Python-list mailing list