This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Bernt.Røskar.Brenna, astrand, gps, neologix, r.david.murray, sbt, tim.golden, vstinner
Date 2013-11-21.09:34:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385026480.09.0.685532038185.issue19575@psf.upfronthosting.co.za>
In-reply-to
Content
In Python 3.3, open_noinherit_ctypes() can be written:

def opener_noinherit(filename, flags):
    return os.open(filename, flags | os.O_NOINHERIT)
f = open(filename, opener=opener_noinherit)


Example on Linux with O_CLOEXEC:

$ python3
Python 3.3.0 (default, Sep 29 2012, 22:07:38) 
[GCC 4.7.2 20120921 (Red Hat 4.7.2-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> def opener_noinherit(filename, flags):
...     return os.open(filename, flags | os.O_CLOEXEC)
... 
>>> f=open("/etc/issue", opener=opener_noinherit)
>>> import fcntl
>>> fcntl.fcntl(f.fileno(), fcntl.F_GETFD) & fcntl.FD_CLOEXEC
1
History
Date User Action Args
2013-11-21 09:34:40vstinnersetrecipients: + vstinner, astrand, gps, tim.golden, r.david.murray, Bernt.Røskar.Brenna, neologix, sbt
2013-11-21 09:34:40vstinnersetmessageid: <1385026480.09.0.685532038185.issue19575@psf.upfronthosting.co.za>
2013-11-21 09:34:40vstinnerlinkissue19575 messages
2013-11-21 09:34:39vstinnercreate