[New-bugs-announce] [issue16946] subprocess: _close_open_fd_range_safe() does not set close-on-exec flag on Linux < 2.6.23 if O_CLOEXEC is defined
STINNER Victor
report at bugs.python.org
Sat Jan 12 15:54:13 CET 2013
New submission from STINNER Victor:
The following extract of _close_open_fd_range_safe() is not correct:
#ifdef O_CLOEXEC
fd_dir_fd = open(FD_DIR, O_RDONLY | O_CLOEXEC, 0);
#else
fd_dir_fd = open(FD_DIR, O_RDONLY, 0);
#ifdef FD_CLOEXEC
{
int old = fcntl(fd_dir_fd, F_GETFD);
if (old != -1)
fcntl(fd_dir_fd, F_SETFD, old | FD_CLOEXEC);
}
#endif
#endif
On Linux older than 2.6.23, O_CLOEXEC may be defined by the glibc whereas the kernel does not support it. In this case, the flag is simply ignored and close-on-exec flag is not set on the file descriptor.
----------
messages: 179803
nosy: haypo, neologix
priority: normal
severity: normal
status: open
title: subprocess: _close_open_fd_range_safe() does not set close-on-exec flag on Linux < 2.6.23 if O_CLOEXEC is defined
versions: Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16946>
_______________________________________
More information about the New-bugs-announce
mailing list