From b26bd15791256a4da0b4d3563ef5bb1a384ea0c3 Mon Sep 17 00:00:00 2001 From: Laurence Withers Date: Tue, 2 Oct 2012 18:50:23 +0000 Subject: [PATCH] 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. --- src/daemonitor/700_signal.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/daemonitor/700_signal.c b/src/daemonitor/700_signal.c index 469c896..e47edd1 100644 --- a/src/daemonitor/700_signal.c +++ b/src/daemonitor/700_signal.c @@ -1,9 +1,9 @@ /* daemonitor/src/daemonitor/700_signal.c * - * (c)2007, Laurence Withers, . - * Released under the GNU GPLv3. See file COPYING or - * http://www.gnu.org/copyleft/gpl.html for details. -*/ + * Copyright: ©2007–2012, Laurence Withers. + * Author: Laurence Withers + * 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); }