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

tongxiaoge report at bugs.python.org
Fri Jan 21 06:55:53 EST 2022


New submission from tongxiaoge <shixuantong at huawei.com>:

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/3    S+   19:41   0:00 python2 fd2.py
root     29442  0.0  0.1  10540  1656 pts/5    S+   19:41   0:00 grep --color=auto python2
VM-0-13-suse:~ #
VM-0-13-suse:~ # ps -aux|grep sleep
root     29415  0.0  0.1   5760  1256 pts/3    S+   19:41   0:00 sleep 12345
root     29451  0.0  0.1  10540  1648 pts/5    S+   19:41   0:00 grep --color=auto sleep
VM-0-13-suse:~ #
VM-0-13-suse:~ # ls -l /proc/29415/fd
total 0
lrwx------ 1 root root 64 Jan 21 19:41 0 -> /dev/null
lrwx------ 1 root root 64 Jan 21 19:41 1 -> /dev/pts/3
lrwx------ 1 root root 64 Jan 21 19:41 2 -> /dev/pts/3
VM-0-13-suse:~ #
VM-0-13-suse:~ # kill -9 29415 29414
VM-0-13-suse:~ #
VM-0-13-suse:~ # ps -aux|grep python2
root     29551  0.1  0.7  37096  6632 pts/3    S+   19:42   0:00 python2 fd.py
root     29564  0.0  0.1  10540  1608 pts/5    S+   19:42   0:00 grep --color=auto python2
VM-0-13-suse:~ # ps -aux|grep sleep
root     29552  0.0  0.1   5760  1260 pts/3    S+   19:42   0:00 sleep 12345
root     29576  0.0  0.1  10540  1628 pts/5    S+   19:42   0:00 grep --color=auto sleep
VM-0-13-suse:~ #
VM-0-13-suse:~ # ls -l /proc/29552/fd
total 0
lrwx------ 1 root root 64 Jan 21 19:42 0 -> /dev/null
lrwx------ 1 root root 64 Jan 21 19:42 1 -> /dev/pts/3
lrwx------ 1 root root 64 Jan 21 19:42 2 -> /dev/pts/3
lrwx------ 1 root root 64 Jan 21 19:42 3 -> /dev/null
VM-0-13-suse:~ #
```

in python3.4.6:
```
VM-0-13-suse:~ # python3 -V
Python 3.4.6
VM-0-13-suse:~ # ps -aux|grep python3
root     29086  0.1  0.9  33628  8136 pts/3    S+   19:39   0:00 python3 fd2.py
root     29143  0.0  0.1  10540  1616 pts/5    S+   19:39   0:00 grep --color=auto python3
VM-0-13-suse:~ #
VM-0-13-suse:~ # ps -aux|grep sleep
root     29087  0.0  0.1   5760  1284 pts/3    S+   19:39   0:00 sleep 12345
root     29164  0.0  0.1  10540  1620 pts/5    S+   19:39   0:00 grep --color=auto sleep
VM-0-13-suse:~ #
VM-0-13-suse:~ # ls -l /proc/29087/fd
total 0
lrwx------ 1 root root 64 Jan 21 19:39 1 -> /dev/pts/3
lrwx------ 1 root root 64 Jan 21 19:39 2 -> /dev/pts/3
VM-0-13-suse:~ #
VM-0-13-suse:~ # kill -9 29087 29086
VM-0-13-suse:~ #
VM-0-13-suse:~ # ps -aux|grep python3
root     29257  0.3  0.9  33628  8076 pts/3    S+   19:40   0:00 python3 fd.py
root     29270  0.0  0.1  10540  1620 pts/5    S+   19:40   0:00 grep --color=auto python3
VM-0-13-suse:~ #
VM-0-13-suse:~ # ps -aux|grep sleep
root     29258  0.0  0.1   5760  1264 pts/3    S+   19:40   0:00 sleep 12345
root     29281  0.0  0.1  10540  1628 pts/5    S+   19:40   0:00 grep --color=auto sleep
VM-0-13-suse:~ #
VM-0-13-suse:~ # ls -l /proc/29258/fd
total 0
lrwx------ 1 root root 64 Jan 21 19:40 0 -> /dev/null
lrwx------ 1 root root 64 Jan 21 19:40 1 -> /dev/pts/3
lrwx------ 1 root root 64 Jan 21 19:40 2 -> /dev/pts/3
```

in python3.10.0:
```
bash-5.1# python3 -V
Python 3.10.0
bash-5.1#
bash-5.1# ps -aux|grep python3
root     28688  0.0  0.9  11664  8732 ?        S+   11:36   0:00 python3 fd2.py
root     28725  0.0  0.2   6408  2216 ?        S+   11:36   0:00 grep python3
bash-5.1#
bash-5.1# ps -aux|grep sleep
root     28694  0.0  0.1   5524   908 ?        S+   11:36   0:00 sleep 12345
root     28729  0.0  0.2   6408  2276 ?        S+   11:36   0:00 grep sleep
bash-5.1#
bash-5.1# ls -l /proc/28694/fd
total 0
lrwx------ 1 root root 64 Jan 21 11:36 1 -> /dev/pts/3
lrwx------ 1 root root 64 Jan 21 11:36 2 -> /dev/pts/3
bash-5.1#
bash-5.1#
bash-5.1# kill -9 28694 28688
bash-5.1#
bash-5.1# ps -aux|grep python3
root     28846  0.5  0.9  11680  8428 ?        S+   11:37   0:00 python3 fd.py
root     28854  0.0  0.2   6408  2064 ?        S+   11:37   0:00 grep python3
bash-5.1#
bash-5.1# ps -aux|grep sleep
root     28847  0.0  0.0   5524   872 ?        S+   11:37   0:00 sleep 12345
root     28863  0.0  0.2   6408  2220 ?        S+   11:37   0:00 grep sleep
bash-5.1#
bash-5.1# ls -l /proc/28847/fd
total 0
lrwx------ 1 root root 64 Jan 21 11:37 0 -> /dev/null
lrwx------ 1 root root 64 Jan 21 11:37 1 -> /dev/pts/3
lrwx------ 1 root root 64 Jan 21 11:37 2 -> /dev/pts/3
bash-5.1#
```

When we execute the script fd2.py in the python 3 environment, we can find that  '0 -> /dev/null' is lost. I wonder if this is a bug in Python3 or a new feature? If it is a bug, how to fix it? I will look forward to your reply very much.

----------
components: Library (Lib)
messages: 411113
nosy: shihai1991, sxt1001, vstinner
priority: normal
severity: normal
status: open
title: '0 -> /dev/null' is lost
type: behavior
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46454>
_______________________________________


More information about the New-bugs-announce mailing list