EOF handling in read_line_input

Mark Salter msalter at redhat.com
Tue Sep 7 17:25:36 UTC 2010


On Tue, 2010-09-07 at 18:37 +0200, Denys Vlasenko wrote:
> On Tue, Sep 7, 2010 at 1:57 PM, Mark Salter <msalter at redhat.com> wrote:
> > I am using busybox 1.17.1 and am seeing a hang in hush when a telnet
> > session is closed without an explicit exit. In that case, hush gets a
> > SIGHUP, but hush blocks SIGHUP so that it can be handled synchronously
> > in check_and_run_traps(). The problem is that read_line_input never
> > returns so check_and_run_traps never gets the chance to see the SIGHUP.
> 
> What are the symptoms? hush looping and eating 100% CPU?

Yes.
> 
> > I had to use the following to get read_line_input to return on EOF. Am
> > I missing anything here?
> >
> > diff --git a/libbb/lineedit.c b/libbb/lineedit.c
> > index a9b790c..fe320bf 100644
> > --- a/libbb/lineedit.c
> > +++ b/libbb/lineedit.c
> > @@ -2010,6 +2010,9 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
> >  #endif
> >
> >                switch (ic) {
> > +               case -1:
> > +                       break_out = command_len = -1;
> > +                       break;
> >                case '\n':
> >                case '\r':
> >                vi_case('\n'|VI_CMDMODE_BIT:)
> 
> 
> Thanks! Added the fix to hot fixes:
> 
> http://busybox.net/downloads/fixes-1.17.2/busybox-1.17.2-lineedit.patch
> 
> Does it fix the problem for you?

It does. Thanks.

--Mark




More information about the busybox mailing list