Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Oct 2009 19:02:20 +0200 (CEST)
From:      Alexander Best <alexbestms@math.uni-muenster.de>
To:        <rea-fbsd@codelabs.ru>, Dag-Erling Sm??rgrav <des@des.no>
Cc:        Antony Mawer <lists@mawer.org>, freebsd-hackers@freebsd.org, pluknet <pluknet@gmail.com>, ed@freebsd.org, rafan@freebsd.org
Subject:   Re: help needed to fix contrib/ee crash/exit when receiving SIGWINCH
Message-ID:  <permail-2009102317022080e26a0b00000936-a_best01@message-id.uni-muenster.de>
In-Reply-To: <8gJJDa6kRsCUwxK/zidtHIOFMRw@LbQSLh99U4wa807TkC1GazBU7WI>

next in thread | previous in thread | raw e-mail | index | archive | help
Eygene Ryabinkin schrieb am 2009-10-23:
> Gentlemen, good day.

> Fri, Oct 23, 2009 at 02:02:38PM +0200, Dag-Erling Sm??rgrav wrote:
> > src/contrib/ee/ee.c in 8:

> >                 in = wgetch(text_win);
> >                 if (in == -1)
> >                         exit(0);  /* without this exit ee will go
> >                         into an
> >                                      infinite loop if the network
> >                                      session detaches */

> > >From the wgetch() man page:

> >        Programmers concerned about portability should be prepared
> >        for
> >        either of  two  cases: (a) signal receipt does not interrupt
> >        getch; (b) signal receipt interrupts getch and causes it to
> >        return ERR with errno set  to EINTR.   Under the ncurses
> >        implementation, handled signals never inter???  rupt getch.

> Hmm, we can transform this code to the following one:
> -----
> errno = 0;
> do {
>         in = wgetch(text_win);
> } while (errno == EINTR);
> if (in == -1)
>         exit(0);
> -----
> This won't help with FreeBSD's ncurses, but may be other variants
> will feel much better with such a event loop variant.

> > The real issue, though, is that when a SIGWINCH is caught, wgetch()
> > correctly returns KEY_RESIZE, but the next call to wgetch() returns
> > -1.
> > The next call after that is fine.  I suspect the error lies
> > somewhere
> > inside kgetch() in contrib/ncurses/ncurses/base/lib_getch.c.

> The problem should be healed with the attached patch.  And you're
> partly right: this is kgetch() that is returning ERR for the second
> wgetch(), but kgetch() shouldn't be blamed for this -- _nc_wgetch()
> should.  At least in my opinion ;)

> Any views on this?

oh...and btw. the PR (http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/136223)
hasn't been assigned to anyone yet. could the person who will be committing
the patch please take care of that (maybe setting the PR to
analysed->patched->closed? ;) would be great if this fix could make it into
8.0-RELEASE in time because it's quite nasty to lose all your editor data due
to a SIGWINCH.

cheers.
alex



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?permail-2009102317022080e26a0b00000936-a_best01>