STINNER Victor <vstin...@python.org> added the comment:

I close the issue as "not a bug". If you disagree, please comment the issue :-)

Steven Stewart-Gallus:
> In the code FD_DIR is "/proc/self/fd" on Linux. I'm not sure this code
> is correct. This seems as if it would have the same problems as
> iterating over a list and modifying it at the same time.

I don't understand the initial issue. What makes you think that the current 
code is not reliable? Python is using this code for years, and so far, nobody 
reported any crash on this code.

You didn't report a crash, you only wrote that you suspect that there is a bug. 
Can you prove that the current Python code is wrong? Did you look at the 
implementation of readdir() in the Linux glibc for example?

About close() vs marking file descriptor non inheritable, I'm not convinced 
that marking file descriptors is faster or more reliable. On many operating 
systems, _Py_set_inheritable() requires 2 syscalls (get flags, set flags), 
whereas close() is a single syscall: calling close() is faster.

---

Python now has a _Py_closerange() function which supports:

* Linux closerange() syscall, calling the glibc closerange() function
* FreeBSD closefrom() function
* Solaris fdwalk() function

On Linux, _posixsubprocess still iterates /proc/self/pid/ if this directory can 
be opened, even if the closerange() function is available. I'm not sure which 
option is the safest or the fastest. 

By the way, Steven Stewart-Gallus did mention his operating system.

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue21627>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to