https://bugzilla.mindrot.org/show_bug.cgi?id=3280
Bug ID: 3280 Summary: stdout resource unavailable error when used with a pipe Product: Portable OpenSSH Version: 8.5p1 Hardware: PPC OS: AIX Status: NEW Severity: normal Priority: P5 Component: ssh Assignee: unassigned-b...@mindrot.org Reporter: sanum...@in.ibm.com Hello when a script that has ssh and cat is passed onto a pipe command then there is a error seen as resource unavailable. Recreation : # cat tp.sh #!/usr/bin/ksh93 export LANG=C { ssh localhost hostname cat /usr/bin/mksysb } | sleep 10 execution output : # ./tp.sh root@localhost's password: cat: output error Resource temporarily unavailable Possible root cause : 1 ssh calls dup() to copy stdout(fd=1) to fd=5. 2 ssh sets O_NONBLOCK flag to fd=5. 3 ssh calls dup2() to assign /dev/null(fd=7) to fd=1. then, ssh closes fd=7. so fd=1 -> /dev/null and fd=5 -> ssh's stdout 4- ssh calls unset_nonblock() to try to clear O_NONBLOCK from fd=1, but it can't because /dev/null has been assigned to fd=1. ssh doesn't clear O_NONBLOCK from ssh's stdout which is fd=5 and ssh closes its stdout(fd=5) without clearing O_NONBLOCK. 5- The subsequent program "cat", fails to write buffers to its stdout, because cat's stdout is connected to the same pipe as ssh, which still has O_NONBLOCK. When executed in debug mode, we get the following error : debug3: send packet: type 1 debug1: fd 0 clearing O_NONBLOCK debug3: fd 1 is not O_NONBLOCK <<<<<< debug1: fd 2 clearing O_NONBLOCK Transferred: sent 1940, received 2424 bytes, in 0.0 seconds Bytes per second: sent 48522.2, received 60627.8 debug1: Exit status 0 cat: output error Resource temporarily unavailable Note: This error is not seen in 7.5p1. If the step 3 mentioned above is commented, then no issue is seen. Please advice on how this can be fixed ? Thanks -- You are receiving this mail because: You are watching the assignee of the bug. _______________________________________________ openssh-bugs mailing list openssh-bugs@mindrot.org https://lists.mindrot.org/mailman/listinfo/openssh-bugs