Subject: Re: telnet loop while trying to flush revoked tty FD
To: Bill Studenmund <wrstuden@netbsd.org>
From: john heasley <heas@shrubbery.net>
List: tech-net
Date: 06/03/2003 22:48:44
Mon, Jun 02, 2003 at 02:32:08PM -0700, Bill Studenmund:
> On Sat, 31 May 2003, john heasley wrote:
> 
> > I ran this patch by Matthias and Martin.  They did not notice anything
> > wrong with the patch described below, but were concerned that it might
> > be masking a bug that is the root cause and since I am not certain how
> > telnet reached the described state, they thought it best to solicit
> > further comment here.
> 
> Well, how about we figure out more what's going on then? :-)

:) I will try to reproduce it.  probably be a week before i can get
back to this.  Thanks for the reply!

> > so, here goes....
> >
> > I am not positive how telnet gets into this situation; undoubtedly it
> > is expect or me doing something dumb with expect.  However, it appears
> > that while telnet is trying to exit, it can get stuck in it's final
> > attempt to flush it's tty when the tty is already dead.
> >
> > In the instance that I caught, lsof indicated that the filedescriptor
> > had been revoked, like so:
> >
> > telnet  22519 heas    0u  VBAD                            (revoked)
> > telnet  22519 heas    1u  VBAD                            (revoked)
> > telnet  22519 heas    2u  VBAD                            (revoked)
> >
> > causing it to loop in SetForExit->EmptyTerminal.
> >
> > Besides updating this comment that i stumbled upon, I changed changed
> > EmptyTerminal to return when ttyflush returns "permanent failure"
> 
> What exactly is EmptyTerminal trying to do? What is the loop you're
> escaping out of waiting for?

I am unsure.  could be anything, but I'd guess that it was something
along the lines of "Connection closed by remote".  that is, the parent
process (expect) went away in some fashion and at some later time the
remote host closed the session due to it's inactivity timer.