X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fprocess.c;h=d88ff970f457ea66ae26d35a95713025e659937c;hb=refs%2Fheads%2F1.1-threads;hp=c1ad81fac1dbd4cbbe844f35db5c73922fd448c1;hpb=6c987fcbc5a1e2394dcbcd999d265cb9826be82b;p=tinc diff --git a/src/process.c b/src/process.c index c1ad81fa..d88ff970 100644 --- a/src/process.c +++ b/src/process.c @@ -166,7 +166,7 @@ DWORD WINAPI controlhandler(DWORD request, DWORD type, LPVOID boe, LPVOID bah) { return ERROR_CALL_NOT_IMPLEMENTED; } - abort(); + running = false; status.dwWaitHint = 30000; status.dwCurrentState = SERVICE_STOP_PENDING; SetServiceStatus(statushandle, &status); @@ -342,6 +342,14 @@ bool execute_script(const char *name, char **envp) { */ #ifndef HAVE_MINGW +static RETSIGTYPE sigterm_handler(int a) { + logger(LOG_NOTICE, "Got %s signal", "TERM"); + if(running) + running = false; + else + exit(1); +} + static RETSIGTYPE fatal_signal_square(int a) { logger(LOG_ERR, "Got another fatal signal %d (%s): not restarting.", a, strsignal(a)); @@ -382,11 +390,15 @@ static struct { int signal; void (*handler)(int); } sighandlers[] = { + {SIGTERM, sigterm_handler}, + {SIGQUIT, sigterm_handler}, + {SIGINT, sigterm_handler}, {SIGSEGV, fatal_signal_handler}, {SIGBUS, fatal_signal_handler}, {SIGILL, fatal_signal_handler}, {SIGPIPE, ignore_signal_handler}, {SIGCHLD, ignore_signal_handler}, + {SIGALRM, ignore_signal_handler}, {0, NULL} }; #endif