handle deficient signal systems
Pull in the sigaction module from gnulib, and add ifdef checks for a bunch of signals that don't exist on Windows.master
parent
7c2cfd6e0c
commit
cab33779ae
|
@ -13,6 +13,7 @@ modules="
|
||||||
iswblank
|
iswblank
|
||||||
lstat
|
lstat
|
||||||
regex
|
regex
|
||||||
|
sigaction
|
||||||
snprintf-posix
|
snprintf-posix
|
||||||
stdarg
|
stdarg
|
||||||
strcase
|
strcase
|
||||||
|
|
14
src/nano.c
14
src/nano.c
|
@ -1173,11 +1173,15 @@ void signal_init(void)
|
||||||
memset(&act, 0, sizeof(struct sigaction));
|
memset(&act, 0, sizeof(struct sigaction));
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
sigaction(SIGINT, &act, NULL);
|
sigaction(SIGINT, &act, NULL);
|
||||||
|
#ifdef SIGQUIT
|
||||||
sigaction(SIGQUIT, &act, NULL);
|
sigaction(SIGQUIT, &act, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Trap SIGHUP and SIGTERM because we want to write the file out. */
|
/* Trap SIGHUP and SIGTERM because we want to write the file out. */
|
||||||
act.sa_handler = handle_hupterm;
|
act.sa_handler = handle_hupterm;
|
||||||
|
#ifdef SIGHUP
|
||||||
sigaction(SIGHUP, &act, NULL);
|
sigaction(SIGHUP, &act, NULL);
|
||||||
|
#endif
|
||||||
sigaction(SIGTERM, &act, NULL);
|
sigaction(SIGTERM, &act, NULL);
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
@ -1189,17 +1193,23 @@ void signal_init(void)
|
||||||
/* Trap normal suspend (^Z) so we can handle it ourselves. */
|
/* Trap normal suspend (^Z) so we can handle it ourselves. */
|
||||||
if (!ISSET(SUSPEND)) {
|
if (!ISSET(SUSPEND)) {
|
||||||
act.sa_handler = SIG_IGN;
|
act.sa_handler = SIG_IGN;
|
||||||
|
#ifdef SIGTSTP
|
||||||
sigaction(SIGTSTP, &act, NULL);
|
sigaction(SIGTSTP, &act, NULL);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* Block all other signals in the suspend and continue handlers.
|
/* Block all other signals in the suspend and continue handlers.
|
||||||
* If we don't do this, other stuff interrupts them! */
|
* If we don't do this, other stuff interrupts them! */
|
||||||
sigfillset(&act.sa_mask);
|
sigfillset(&act.sa_mask);
|
||||||
|
|
||||||
act.sa_handler = do_suspend;
|
act.sa_handler = do_suspend;
|
||||||
|
#ifdef SIGTSTP
|
||||||
sigaction(SIGTSTP, &act, NULL);
|
sigaction(SIGTSTP, &act, NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
act.sa_handler = do_continue;
|
act.sa_handler = do_continue;
|
||||||
|
#ifdef SIGCONT
|
||||||
sigaction(SIGCONT, &act, NULL);
|
sigaction(SIGCONT, &act, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1231,11 +1241,15 @@ RETSIGTYPE do_suspend(int signal)
|
||||||
/* Trap SIGHUP and SIGTERM so we can properly deal with them while
|
/* Trap SIGHUP and SIGTERM so we can properly deal with them while
|
||||||
* suspended. */
|
* suspended. */
|
||||||
act.sa_handler = handle_hupterm;
|
act.sa_handler = handle_hupterm;
|
||||||
|
#ifdef SIGHUP
|
||||||
sigaction(SIGHUP, &act, NULL);
|
sigaction(SIGHUP, &act, NULL);
|
||||||
|
#endif
|
||||||
sigaction(SIGTERM, &act, NULL);
|
sigaction(SIGTERM, &act, NULL);
|
||||||
|
|
||||||
/* Do what mutt does: send ourselves a SIGSTOP. */
|
/* Do what mutt does: send ourselves a SIGSTOP. */
|
||||||
|
#ifdef SIGSTOP
|
||||||
kill(0, SIGSTOP);
|
kill(0, SIGSTOP);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The version of above function that is bound to a key. */
|
/* The version of above function that is bound to a key. */
|
||||||
|
|
Loading…
Reference in New Issue