Hello, I was chasing an issue with bash signal handling on QNX, when I noticed that, whenever you hit enter, the readline library does the following for a few signals:
1. Install a new signal handler via sigaction() 2. Check the previous handler, as returned by this call 3. If it is SIG_IGN, call sigaction() again to restore SIG_IGN Since bash ignores these signals to begin with, all three actions are taken for each signal every time. In addition to being redundant, the sequence above introduces a window in which a signal can come in, with the end result that bash gets the signal itself (which would be very unfortunate if the signal is SIGTSTP). This may be mostly a theoretical issue, but why have the window at all? Is there any reason to allow readline to change signal handling at all? If there is, then perhaps consider the following change, which I currently have defined for QNX only. Thoughts? Thanks, --Elad Index: signals.c =================================================================== --- signals.c (revision 4739) +++ signals.c (working copy) @@ -379,6 +379,17 @@ static void rl_maybe_set_sighandler (int sig, SigHandler *handler, sighandler_cxt *ohandler) { +#ifdef __QNX__ + struct sigaction oact; + + /* Check for SIG_IGN without installing and then removing a new handler. + Avoids potential race conditions in the window between the two actions. */ + sigaction (sig, NULL, &oact); + if (oact.sa_handler != SIG_IGN) + rl_set_sighandler (sig, handler, ohandler); + else + ohandler->sa_handler = SIG_IGN; +#else sighandler_cxt dummy; SigHandler *oh; @@ -387,6 +398,7 @@ oh = rl_set_sighandler (sig, handler, ohandler); if (oh == (SigHandler *)SIG_IGN) rl_sigaction (sig, ohandler, &dummy); +#endif } /* Set the disposition of SIG to HANDLER, if HANDLER->sa_handler indicates the