From 13e4474551ccec777c78fab783105093fd47c42d Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Fri, 27 May 2011 22:41:41 +0200 Subject: [PATCH] Ignore first SIGINT Add a counter to ignore the first ctrl+c (especially useful when sessiond spawn kconsumerd). If the user presses ctrl+c an other time, kconsumerd dies as expected. Signed-off-by: Julien Desfossez --- kconsumerd/kconsumerd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kconsumerd/kconsumerd.c b/kconsumerd/kconsumerd.c index 8e8f1a618..adc1f1bed 100644 --- a/kconsumerd/kconsumerd.c +++ b/kconsumerd/kconsumerd.c @@ -67,6 +67,9 @@ static int poll_pipe[2]; /* socket to communicate errors with sessiond */ static int error_socket = -1; +/* to count the number of time the user pressed ctrl+c */ +static int sigintcount = 0; + /* Argument variables */ int opt_quiet; int opt_verbose; @@ -185,6 +188,11 @@ end: */ static void sighandler(int sig) { + if (sig == SIGINT && sigintcount++ == 0) { + DBG("ignoring first SIGINT"); + return; + } + cleanup(); return; -- 2.34.1