X-Git-Url: http://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Ftty%2Flib_tstp.c;h=583ee0fdd5053d2fd06aa9375694ca092199870a;hb=bd75bb126bdbd8300fe73e8e8b2fe97bd07eef75;hp=6ccdfc74a27f631db6244d408dcb8de351fa68f1;hpb=8a0f1799616236ed1bc59aba36d3cc924fe39577;p=ncurses.git diff --git a/ncurses/tty/lib_tstp.c b/ncurses/tty/lib_tstp.c index 6ccdfc74..583ee0fd 100644 --- a/ncurses/tty/lib_tstp.c +++ b/ncurses/tty/lib_tstp.c @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: lib_tstp.c,v 1.42 2011/04/16 16:42:10 tom Exp $") +MODULE_ID("$Id: lib_tstp.c,v 1.44 2011/06/25 21:22:16 tom Exp $") #if defined(SIGTSTP) && (HAVE_SIGACTION || HAVE_SIGVEC) #define USE_SIGTSTP 1 @@ -240,16 +240,19 @@ cleanup(int sig) SCREEN *sp = CURRENT_SCREEN; /* - * Actually, doing any sort of I/O from within an signal handler is - * "unsafe". But we'll _try_ to clean up the screen and terminal - * settings on the way out. + * Much of this is unsafe from a signal handler. But we'll _try_ to clean + * up the screen and terminal settings on the way out. + * + * There are at least the following problems: + * 1) Walking the SCREEN list is unsafe, since all list management + * is done without any signal blocking. + * 2) On systems which have REENTRANT turned on, set_term() uses + * _nc_lock_global() which could deadlock or misbehave in other ways. + * 3) endwin() calls all sorts of stuff, many of which use stdio or + * other library functions which are clearly unsafe. */ if (!_nc_globals.cleanup_nested++ - && (sig == SIGINT -#ifdef SIGQUIT - || sig == SIGQUIT -#endif - )) { + && (sig == SIGINT || sig == SIGTERM)) { #if HAVE_SIGACTION || HAVE_SIGVEC sigaction_t act; sigemptyset(&act.sa_mask); @@ -270,11 +273,11 @@ cleanup(int sig) set_term(scan); NCURSES_SP_NAME(endwin) (NCURSES_SP_ARG); if (sp) - sp->_endwin = FALSE; /* in case we have an atexit! */ + sp->_endwin = FALSE; /* in case of reuse */ } } } - exit(EXIT_FAILURE); + _exit(EXIT_FAILURE); } #if USE_SIGWINCH