[New-bugs-announce] [issue31712] subprocess with stderr=subprocess.STDOUT hang

l4mer report at bugs.python.org
Fri Oct 6 07:39:10 EDT 2017


New submission from l4mer <janusz.dziedzic at gmail.com>:

I am using ssh mux + authorized key. So can exectute commands without passwod.

1. disconnect mux by: ssh user at localhost -O exit
2. run simple script
import subprocess

if __name__ == '__main__':
    cmd = ["ssh", "user at localhost", "id"]
    try:
        buf = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as e:
        buf = e.output
3. This always hang in read(3,
fcntl(3, F_GETFL)                       = 0 (flags O_RDONLY)
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f036b5f1000
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
munmap(0x7f036b5f1000, 4096)            = 0
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "uid=0(", 6)                    = 6
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "root) ", 6)                    = 6
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "gid=0(r", 7)                   = 7
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "oot) gro", 8)                  = 8
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "ups=0(roo", 9)                 = 9
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
read(3, "t)\n", 10)                     = 3
read(3, 0x7f036b480653, 7)              = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=21620, si_status=0, si_utime=1, si_stime=0} ---
read(3,

4. After ctr+c
read(3, ^CProcess 21619 detached
 <detached ...>
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    buf = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
  File "/usr/lib/python2.7/subprocess.py", line 567, in check_output
    output, unused_err = process.communicate()
  File "/usr/lib/python2.7/subprocess.py", line 791, in communicate
wigig at wigig-Latitude-E5270:~$     stdout = _eintr_retry_call(self.stdout.read)
  File "/usr/lib/python2.7/subprocess.py", line 476, in _eintr_retry_call
    return func(*args)

BTW, when MUX is created it always works.

----------
messages: 303815
nosy: l4mer
priority: normal
severity: normal
status: open
title: subprocess with stderr=subprocess.STDOUT hang
type: behavior
versions: Python 2.7

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


More information about the New-bugs-announce mailing list