From d1e01bc880a6970050e55f19bafe8eaf1f0b9be2 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 25 Jul 2013 17:14:07 +0200 Subject: [PATCH] Allow control-C to stop tincd without stopping the tinc shell. --- src/tincctl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tincctl.c b/src/tincctl.c index d02bda52..a4965484 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -830,8 +830,16 @@ static int cmd_start(int argc, char *argv[]) { free(nargv); - int status = -1; - if(waitpid(pid, &status, 0) != pid || !WIFEXITED(status) || WEXITSTATUS(status)) { + int status = -1, result; +#ifdef SIGINT + signal(SIGINT, SIG_IGN); +#endif + result = waitpid(pid, &status, 0); +#ifdef SIGINT + signal(SIGINT, SIG_DFL); +#endif + + if(result != pid || !WIFEXITED(status) || WEXITSTATUS(status)) { fprintf(stderr, "Error starting %s\n", c); return 1; }