static sigset_t _oldset;
static int _signals_blocked = 0;
static volatile sig_atomic_t _sigint_caught = 0;
-static volatile sig_atomic_t _handler_installed;
+static volatile sig_atomic_t _handler_installed = 0;
/* Support 3 level nesting, increase if needed more */
#define MAX_SIGINTS 3
* Do not overwrite the backed-up handler data -
* just increase nesting count.
*/
- if (++_handler_installed >= MAX_SIGINTS)
+ if (++_handler_installed > MAX_SIGINTS)
return;
/* Grab old sigaction for SIGINT: shall not fail. */
if (sigprocmask(0, NULL, &sigs))
log_sys_debug("sigprocmask", "");
- if ((_oldmasked[_handler_installed] = sigismember(&sigs, SIGINT))) {
+ if ((_oldmasked[_handler_installed - 1] = sigismember(&sigs, SIGINT))) {
sigdelset(&sigs, SIGINT);
if (sigprocmask(SIG_SETMASK, &sigs, NULL))
log_sys_debug("sigprocmask", "SIG_SETMASK");
return;
if (!_handler_installed ||
- --_handler_installed >= MAX_SIGINTS)
+ --_handler_installed > MAX_SIGINTS)
return;
/* Nesting count went below MAX_SIGINTS. */