[issue23458] [2.7] random: make the file descriptor non-inheritable (on POSIX)

Pavel Labath report at bugs.python.org
Tue Feb 24 14:48:16 CET 2015


Pavel Labath added the comment:

Thanks for fixing this.

Still, I would like to argue that an atomic operation is important. Python interpreter can run embedded in an multi-threaded application (as we do in the case of LLDB). If this is the case, then file descriptors opened by python in one thread are visible to other application threads even though they may have nothing to do with python -- they may not even know that python exists. Now if these other threads do a fork between the time you do open() and fcntl(), you've got yourself a race condition.

Granted, this is not very likely, but this is precisely the reason why O_CLOEXEC was created, and I think we should take advantage of that. And it is not even linux specific, the flag is now recent versions of mac and freebsd too. Therefore I think the original patch is better, even though it may be more complex.

----------

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


More information about the Python-bugs-list mailing list