Treat SIGINT similarly to SIGTERM
Treat SIGINT similarly to SIGTERM; exit when it is received. This gives the desired behaviour of having a foreground daemonitor be stopped by pressing ctrl-C on its controlling tty.
This commit is contained in:
parent
f611c2acf7
commit
b26bd15791
|
@ -1,9 +1,9 @@
|
||||||
/* daemonitor/src/daemonitor/700_signal.c
|
/* daemonitor/src/daemonitor/700_signal.c
|
||||||
*
|
*
|
||||||
* (c)2007, Laurence Withers, <l@lwithers.me.uk>.
|
* Copyright: ©2007–2012, Laurence Withers.
|
||||||
* Released under the GNU GPLv3. See file COPYING or
|
* Author: Laurence Withers <l@lwithers.me.uk>
|
||||||
* http://www.gnu.org/copyleft/gpl.html for details.
|
* License: GPLv3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,8 +72,9 @@ void signal_setup(void)
|
||||||
sigdelset(&ss, SIGSEGV);
|
sigdelset(&ss, SIGSEGV);
|
||||||
sigdelset(&ss, SIGBUS);
|
sigdelset(&ss, SIGBUS);
|
||||||
|
|
||||||
/* we'd like to deal with SIGTERM specially */
|
/* we'd like to deal with SIGTERM/SIGINT specially */
|
||||||
sigdelset(&ss, SIGTERM);
|
sigdelset(&ss, SIGTERM);
|
||||||
|
sigdelset(&ss, SIGINT);
|
||||||
|
|
||||||
/* don't block SIGCHLD or wait(2) won't work */
|
/* don't block SIGCHLD or wait(2) won't work */
|
||||||
sigdelset(&ss, SIGCHLD);
|
sigdelset(&ss, SIGCHLD);
|
||||||
|
@ -90,9 +91,10 @@ void signal_setup(void)
|
||||||
sigaction(SIGBUS, &sa, 0);
|
sigaction(SIGBUS, &sa, 0);
|
||||||
sigaction(SIGCHLD, &sa, 0);
|
sigaction(SIGCHLD, &sa, 0);
|
||||||
|
|
||||||
/* install our own handler for SIGTERM */
|
/* install our own handler for SIGTERM/SIGINT */
|
||||||
sa.sa_handler = sigterm_handler;
|
sa.sa_handler = sigterm_handler;
|
||||||
sigaction(SIGTERM, &sa, 0);
|
sigaction(SIGTERM, &sa, 0);
|
||||||
|
sigaction(SIGINT, &sa, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue