so-called-hang-on-exit

Frank Cusack fcusack at fcusack.com
Tue Aug 6 14:41:36 EST 2002


On Tue, Aug 06, 2002 at 01:14:22AM +0300, Jani Jaakkola wrote:
> On Mon, 5 Aug 2002, Frank Cusack wrote:
> 
> > I've implemented something similar for protocol 1, and implemented a
> > slightly simpler version of your patch for protocol 2.  Before I post it,
> > I'm curious as to what the intent is of being able to specify the
> > select() timeout.
> 
> The point of the select() timeout was to make sure, that sshd never gets 
> stuck on select, if there never was no output from the background 
> processes and pty buffer already was empty. 

Oh right.  Cuz it might set the tvp to NULL.  I think it's simpler just
to use the child_terminated flag, just don't reset it in the ssh2 code
path (this doesn't seem to have a point other than skipping the call
to waitpid() after the first child terminates).

> Anyway, I realized that it is probably useless to go through the select 
> loop after the child is exited to just be able to empty the pty buffer. I 
> checked, and Linux pty buffer size is just 2048 bytes, which is much less 
> than 16*1024 buffer in channel_handle_rfd. And since the master processes 
> have exited, the unread data is guaranteed to have fit into that 2048 byte 
> buffer.

Yeah, but you don't know how much of that buffer is available, and the bug
isn't present only on Linux, I thought.  I actually tried just emptying
the buffer and then doing a chan_read_failed() but this lost data for me.
At least I think I tried that. :-)

I'll put up my patch for comparison later tonight.

/fc



More information about the openssh-unix-dev mailing list