[issue16860] Use O_CLOEXEC in the tempfile module

STINNER Victor report at bugs.python.org
Fri Jan 4 15:35:46 CET 2013


STINNER Victor added the comment:

> Here's the patch.

_set_cloexec() is still called whereas it is useless if the OS supports O_CLOEXEC... But the call must be kept because Linux < 2.6.23 just ignores O_CLOEXEC: we would have to check _fcntl.fcntl(fd, _fcntl.F_GETFD, 0) & _fcntl.FD_CLOEXEC to check if the kernel does really support O_CLOEXEC, which is overkill. The possibly useless syscall doesn't hurt.

> (if the file is created with O_CREAT|O_EXCL, then by definition it's not a symlink).

Ah yes, because of O_EXCL.

The patch looks good to me!

----------

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


More information about the Python-bugs-list mailing list