[Bug 1102] C program 'write' with zero length hangs

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Thu Oct 13 21:31:18 EST 2005


http://bugzilla.mindrot.org/show_bug.cgi?id=1102





------- Comment #10 from dtucker at zip.com.au  2005-10-13 21:31 -------
Created an attachment (id=994)
 --> (http://bugzilla.mindrot.org/attachment.cgi?id=994&action=view)
only close connection for zero-length stdin reads when errno set

I don't think that your program isn't really hanging, although it looks that
way.  What I think is happening is that your zero-length write results in a
zero length read in sshd, which results in the channel being shut down.

sshd is waiting for all of the file descriptors to close, while your program
(or the shell) is waiting for its stdin to be read.  With them deadlocked, it
would appear that the sshd session hung.

I just read the SuSv3 specs for read(2)
(http://www.opengroup.org/onlinepubs/000095399/functions/read.html).  It's not
clear but it appears that returning a zero-length read is permitted for STREAMS
sockets (although I didn't think AIX's pty layer was STREAMS based).  So, AIX's
behaviour might be compliant, although quite unusual.

Anyway, please try the attached patch (against -current but should apply to
4.1p1 or 4.2p1).  It's a bit ugly but it seems to be the only way to handle the
zero-length case, assuming the above is correct.




------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.




More information about the openssh-bugs mailing list