fork/exec & close file descriptors

Marko Rauhamaa marko at pacujo.net
Wed Jun 3 03:41:44 EDT 2015


Alain Ketterlin <alain at universite-de-strasbourg.fr.invalid>:

> Marko Rauhamaa <marko at pacujo.net> writes:
>> Maybe close() will fail for ever.
>
> Your program has to deal with this, something is going wrong, it can't
> just close and go on.

Here's the deal: the child process is saddled with file descriptors it
never wanted in the first place. It can't decline them. Now you're
saying it can't even dispose of them.

The reason this has been allowed to go on is that everybody just closes
the file descriptors and ignores the possibility or repercussions of a
failure. I haven't read about horror stories of this failing.

I readily admit this is very dirty, but since the API doesn't offer a
clean alternative, there's nothing you can/should do about it.


Marko



More information about the Python-list mailing list