OpenSSH and non-blocking mode

Damien Miller djm at mindrot.org
Thu Jul 7 09:49:30 EST 2005


Larry Jones wrote:
> Dear OpenSSH developers,
> 
> OpenSSH setting non-blocking mode on its standard files creates serious
> problems.

I don't think your analysis is correct: setting nonblock on one side of
a stdio connection shouldn't affect the other side (see the attached
test program).

> 	$ cat bigfile | wc -c
> 	 10858893
> 	$ (ssh localhost sleep 120& sleep 3; cat bigfile) | wc -c
> 	cat: stdout: Resource temporarily unavailable
> 	  270336

What platform are you using? This works fine on OpenBSD and Solaris.
You could be running into a kernel bug.

> I understand the necessity to keep ssh from blocking in order to keep
> port-forwarding working, but wouldn't it be possible to do that by just
> selecting for write before trying to write to stdout or stderr rather
> than setting non-blocking mode?

No - we cannot turn of non-blocking stdio in OpenSSH. select() will tell
you that a fd is ready for writing, but not how much data you can write.
So unless you are willing to do your IO one byte at a time,  select()ing
for each byte, you can still block.

-d
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testnonblock.c
Url: http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20050707/97f35718/attachment.c 


More information about the openssh-unix-dev mailing list