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:
Laurence Withers 2012-10-02 18:50:23 +00:00
parent f611c2acf7
commit b26bd15791
1 changed files with 8 additions and 6 deletions

View File

@ -1,9 +1,9 @@
/* daemonitor/src/daemonitor/700_signal.c
*
* (c)2007, Laurence Withers, <l@lwithers.me.uk>.
* Released under the GNU GPLv3. See file COPYING or
* http://www.gnu.org/copyleft/gpl.html for details.
*/
* Copyright: ©20072012, Laurence Withers.
* Author: Laurence Withers <l@lwithers.me.uk>
* License: GPLv3
*/
@ -72,8 +72,9 @@ void signal_setup(void)
sigdelset(&ss, SIGSEGV);
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, SIGINT);
/* don't block SIGCHLD or wait(2) won't work */
sigdelset(&ss, SIGCHLD);
@ -90,9 +91,10 @@ void signal_setup(void)
sigaction(SIGBUS, &sa, 0);
sigaction(SIGCHLD, &sa, 0);
/* install our own handler for SIGTERM */
/* install our own handler for SIGTERM/SIGINT */
sa.sa_handler = sigterm_handler;
sigaction(SIGTERM, &sa, 0);
sigaction(SIGINT, &sa, 0);
}