Message203596
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 |
|
Date |
User |
Action |
Args |
2013-11-21 09:34:40 | vstinner | set | recipients:
+ vstinner, astrand, gps, tim.golden, r.david.murray, Bernt.Røskar.Brenna, neologix, sbt |
2013-11-21 09:34:40 | vstinner | set | messageid: <1385026480.09.0.685532038185.issue19575@psf.upfronthosting.co.za> |
2013-11-21 09:34:40 | vstinner | link | issue19575 messages |
2013-11-21 09:34:39 | vstinner | create | |
|