[CentralOH] Popen file descriptor difference between Python 2.6 and 2.7+ on Linux

Neil Ludban nludban at columbus.rr.com
Fri Feb 16 23:32:41 EST 2018


On Fri, 16 Feb 2018 22:34:35 -0500
Eric Floehr <eric at intellovations.com> wrote:
> I have a really odd problem. I have some code that requires a Linux file
> descriptor (/dev/fd/N) where N is some number. The following example code
> demonstrates effectively what is being done.
> 
> In order to run the code create a file called "/tmp/test" with some text in
> it.
> 
> The code works in Python 2.6, but in Python 2.7 or later, I get:
> 
> cat: /dev/fd/4: No such file or directory

Smells like a back-porting of adding the O_CLOEXEC flag...

     Unless O_CLOEXEC flag was specified, the new descriptor is set to remain
     open across execve(2) system calls; see close(2), fcntl(2) and O_CLOEXEC
     description.

https://www.python.org/dev/peps/pep-0446/


More information about the CentralOH mailing list