[issue12105] open() does not able to set flags, such as O_CLOEXEC

Charles-François Natali report at bugs.python.org
Thu May 19 20:38:54 CEST 2011


Charles-François Natali <neologix at free.fr> added the comment:

Here's a patch adding O_CLOEXEC to the os module, with test. This patch makes it possible to open and set a FD CLOEXEC atomically.
O_CLOEXEC is part of POSIX.1-2008, supported by the Linux kernel since 2.6.23 and has been committed recently to FreeBSD.
Note that I'm not sure that adding this flag to built-in open() is necessarily a good idea, because it's not portable and low-level.
The same functionality can be more or less achieved with:
f = os.fdopen(os.open('/etc/fstab', os.O_RDONLY|os.O_CLOEXEC))

----------
keywords: +patch
nosy: +haypo
Added file: http://bugs.python.org/file22031/os_cloexec.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12105>
_______________________________________


More information about the Python-bugs-list mailing list