[Python-Dev] Add "e" (close and exec) mode to open()

Benjamin Peterson benjamin at python.org
Tue Jan 8 17:08:02 CET 2013


2013/1/8 Victor Stinner <victor.stinner at gmail.com>:
> Oops, I sent my email too early by mistake (it was not finished).
>
>> The myriad cloexec
>> APIs between different platforms suggests to me that using this
>> features requires understanding its various quirks on different
>> platforms.
>
> Sorry, I don't understand. What do you mean by "various quirks". The
> "close-on-exec" feature is implemented differently depending on the
> platform, but it always have the same meaning. It closes the file when
> a subprocess is created. Running a subprocess is also implemented
> differently depending on the OS, there are two mains approaches:
> fork()+exec() on UNIX, <something else> on Windows (I don't know how
> it works on Windows).
>
> Extract of fcntl() manual page on Linux: "If the FD_CLOEXEC  bit  is
> 0, the file descriptor will remain open across an execve(2), otherwise
> it will be closed."
>
> I would like to expose the OS feature using a portable API to hide the
> "The myriad cloexec APIs".

Okay, fair enough, but I really would like it not to ever raise
NotImplementedError. Then you would end up having different codepaths
for various oses anyway.



-- 
Regards,
Benjamin


More information about the Python-Dev mailing list