[issue46454] '0 -> /dev/null' is lost

2022-01-27 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg411287 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue46454] '0 -> /dev/null' is lost

2022-01-27 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg411776 ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue46454] '0 -> /dev/null' is lost

2022-01-26 Thread Eryk Sun
Eryk Sun added the comment: > stdin is closed > os.open() is called and creates a new fd=0 > a call to os.dup2(fd, 0) is made but is a noop The dup2() silent noop case is a problem, but not the problem that's reported in msg43. The two examples for this issue are fd.py and fd2.py. In fd.

[issue46454] '0 -> /dev/null' is lost

2022-01-25 Thread Brett Randall
Brett Randall added the comment: docker run -i --rm python:3.9 <<-EOF import os print(os.get_inheritable(0)) fd_null_before_close = os.open("/dev/null", os.O_RDWR) os.close(0) fd_null = os.open("/dev/null", os.O_RDWR) print(fd_null_before_close) print(fd_null) os.dup2(fd_null, 0) print(os.

[issue46454] '0 -> /dev/null' is lost

2022-01-25 Thread Brett Randall
Brett Randall added the comment: For the possible benefit of future readers of this issue, the sequence and behaviour here which may cause confusion: - say stdin is closed, perhaps along with stdout and stderr via a call to os.closerange(0, 3) or otherwise - os.open() is called and creates a

[issue46454] '0 -> /dev/null' is lost

2022-01-25 Thread Brett Randall
Change by Brett Randall : -- nosy: +javabrett ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue46454] '0 -> /dev/null' is lost

2022-01-22 Thread STINNER Victor
Change by STINNER Victor : -- nosy: -vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue46454] '0 -> /dev/null' is lost

2022-01-22 Thread Eryk Sun
Eryk Sun added the comment: > If some one closes fd 0, then he reopens it. it will not be inherited. In Windows, when a console process spawns a child console process without enabling handle inheritance -- e.g. subprocess.Popen(['python.exe']) -- the OS will manually duplicate (not inherit)

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread licunlong
licunlong added the comment: > File descriptors 0, 1, 2 are special: stdin, stdout and stderr file > descriptors. You should use stdin, stdout, and stderr parameter of subprocess. I finally find why `fd 0` is inherited. The reason is that os.dup2() has a parameter "inheritable" which default

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread STINNER Victor
STINNER Victor added the comment: > this fd 0 `is` inherited. File descriptors 0, 1, 2 are special: stdin, stdout and stderr file descriptors. You should use stdin, stdout, and stderr parameter of subprocess. Sorry but the bug tracker is not a good place to ask questions about how to use Py

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread licunlong
licunlong added the comment: But one more question. Please take a look at fd.py. In this file, we first close fd 0, then open /dev/null as fd_null, and dump fd_null to fd 0. After we fork new process, this fd 0 `is` inherited. This seems to be a bug? -- nosy: +Geass-LL _

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread STINNER Victor
STINNER Victor added the comment: That's not a bug, but a deliberate choice. In Python 3, file descriptors are no longer inherited by default by child processes (fork+exec). Jelle is right, it was changed by my PEP 446. You must use pass_fds=[fd] parameter of subprocess. Or at least, make t

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread Jelle Zijlstra
Jelle Zijlstra added the comment: This sounds like a consequence of PEP 446. -- nosy: +Jelle Zijlstra ___ Python tracker ___ ___ Py

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread tongxiaoge
Change by tongxiaoge : Added file: https://bugs.python.org/file50573/python3.10.0-out.png ___ Python tracker ___ ___ Python-bugs-list mailin

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread tongxiaoge
Change by tongxiaoge : Added file: https://bugs.python.org/file50574/python3.4.6-out.png ___ Python tracker ___ ___ Python-bugs-list mailing

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread tongxiaoge
Change by tongxiaoge : Added file: https://bugs.python.org/file50572/python2.7.13-out.png ___ Python tracker ___ ___ Python-bugs-list mailin

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread tongxiaoge
Change by tongxiaoge : Added file: https://bugs.python.org/file50571/fd2.py ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread tongxiaoge
Change by tongxiaoge : Added file: https://bugs.python.org/file50570/fd.py ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscr

[issue46454] '0 -> /dev/null' is lost

2022-01-21 Thread tongxiaoge
New submission from tongxiaoge : I found a problem in the environment of python2 and python3, as follows: in python2: ``` VM-0-13-suse:~ # python2 -V Python 2.7.13 VM-0-13-suse:~ # VM-0-13-suse:~ # ps -aux|grep python2 root 29414 0.1 0.7 37096 6632 pts/3S+ 19:41 0:00 python2 fd2