This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author l4mer
Recipients gregory.p.smith, l4mer, martin.panter, r.david.murray
Date 2017-10-07.08:31:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507365069.45.0.213398074469.issue31712@psf.upfronthosting.co.za>
In-reply-to
Content
janusz@nc6120:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
janusz@nc6120:~$

I) manual check

janusz@nc6120:~$ ssh root@localhost -p 50494 -O exit
janusz@nc6120:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> cmd = ["ssh", "root@localhost", "-p", "50494"]
>>> buf = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
Terminated

janusz@nc6120:~$ ssh root@localhost -p 50494 -O exit
Exit request sent.
janusz@nc6120:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess32
>>> cmd= ["ssh", "root@localhost", "-p", "50494"]
>>> buf = subprocess32.check_output(cmd, stderr=subprocess32.STDOUT)
Terminated

II) strace 

Correct case (mux exist):
pipe2([3, 4], O_CLOEXEC)                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl64(3, F_GETFL)                     = 0 (flags O_RDONLY)
pipe2([5, 6], O_CLOEXEC)                = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb747a768) = 2207
close(6)                                = 0
close(4)                                = 0
brk(0x9741000)                          = 0x9741000
read(5, "", 50000)                      = 0
brk(0x9735000)                          = 0x9735000
close(5)                                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
_llseek(3, 0, 0xbfc1d350, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
read(3, "root\n", 6)                    = 5
read(3, "", 1)                          = 0
close(3)                                = 0
waitpid(2207, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 2207
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2207, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x8183c10, [], 0}, 8) = 0
brk(0x9733000)                          = 0x9733000
exit_group(0)                           = ?
+++ exited with 0 +++

Fail case:
read(7, "menting schedulers (this is what"..., 8192) = 8192
read(7, "\0\0\0_lent\1\0\0\0ht\10\0\0\0h_appendt\5\0\0\0i"..., 4096) = 2240
read(7, "", 4096)                       = 0
close(7)                                = 0
mmap2(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb70c7000
close(6)                                = 0
close(5)                                = 0
close(4)                                = 0
ugetrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=64*1024}) = 0
close(3)                                = 0
pipe2([3, 4], O_CLOEXEC)                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl64(3, F_GETFL)                     = 0 (flags O_RDONLY)
pipe2([5, 6], O_CLOEXEC)                = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0xb7539768) = 2238
close(6)                                = 0
close(4)                                = 0
brk(0xa30e000)                          = 0xa30e000
read(5, "", 50000)                      = 0
brk(0xa302000)                          = 0xa302000
close(5)                                = 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
_llseek(3, 0, 0xbf8a0600, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
read(3, "root\n", 6)                    = 5
read(3, 0xb710db19, 1)                  = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2238, si_uid=1000, si_status=0, si_utime=4, si_stime=1} ---
read(3,
d(3, ^Cstrace: Process 2237 detached
 <detached ...>
janusz@nc6120:~$ Traceback (most recent call last):
  File "test.py", line 6, in <module>
    buf = subprocess32.check_output(cmd, stderr=subprocess32.STDOUT)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 628, in check_output
    output, unused_err = process.communicate(timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 915, in communicate
    stdout = _eintr_retry_call(self.stdout.read)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 543, in _eintr_retry_call
    return func(*args)
KeyboardInterrupt

When hang:
janusz@nc6120:~$ ls -l "/proc/$(pgrep python)/fd/3"
lr-x------ 1 janusz janusz 64 paź  7 10:25 /proc/2336/fd/3 -> pipe:[29858]
janusz@nc6120:~$ lsof |grep 29858
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/108/gvfs
      Output information may be incomplete.
python    2336                janusz    3r     FIFO       0,10      0t0      29858 pipe
ssh       2342                janusz    2w     FIFO       0,10      0t0      29858 pipe
janusz@nc6120:~$
History
Date User Action Args
2017-10-07 08:31:09l4mersetrecipients: + l4mer, gregory.p.smith, r.david.murray, martin.panter
2017-10-07 08:31:09l4mersetmessageid: <1507365069.45.0.213398074469.issue31712@psf.upfronthosting.co.za>
2017-10-07 08:31:09l4merlinkissue31712 messages
2017-10-07 08:31:07l4mercreate