help needed to fix contrib/ee crash/exit when receiving SIGWINCH

Dag-Erling Smørgrav des at des.no
Fri Oct 23 12:02:40 UTC 2009


[cc: ed for ee and rafan for ncurses]

Alexander Best <alexbestms at math.uni-muenster.de> writes:
> i'm not so sure this is entirely ee's fault.

It is *partly* ee's fault.

src/usr.bin/ee/ee.c in 7:

                in = wgetch(text_win);
                if (in == -1)
                        continue;

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.

so ee is not portable (it should not assume that a "handled signal" such
as SIGWINCH does not interrupt wgetch()), but that's not the real issue.

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.

DES
-- 
Dag-Erling Smørgrav - des at des.no


More information about the freebsd-hackers mailing list