diff options
author | Christian Pointner <equinox@anytun.org> | 2015-05-13 19:20:13 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2015-05-13 19:20:13 +0000 |
commit | 67eb0a32f8b2504ef4abeb26d6bcc11454ada5fd (patch) | |
tree | c37bbe0625c5cfb2aad39fb16ee8e5c7edc64348 /src | |
parent | make prefix variable more standard compliant (diff) |
fixed return code after signal
Diffstat (limited to 'src')
-rw-r--r-- | src/sig_handler.c | 8 | ||||
-rw-r--r-- | src/uanytun.c | 14 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/sig_handler.c b/src/sig_handler.c index 5de168e..f23d070 100644 --- a/src/sig_handler.c +++ b/src/sig_handler.c @@ -139,10 +139,10 @@ int signal_handle() for(sig=1; sig < NSIG; ++sig) { if(sigismember(&set, sig)) { switch(sig) { - case SIGINT: log_printf(NOTICE, "SIG-Int caught, exitting"); return_value = 1; break; - case SIGQUIT: log_printf(NOTICE, "SIG-Quit caught, exitting"); return_value = 1; break; - case SIGTERM: log_printf(NOTICE, "SIG-Term caught, exitting"); return_value = 1; break; - case SIGHUP: log_printf(NOTICE, "SIG-Hup caught"); return_value = 2; break; + case SIGINT: log_printf(NOTICE, "SIG-Int caught, exitting"); return_value = SIGINT; break; + case SIGQUIT: log_printf(NOTICE, "SIG-Quit caught, exitting"); return_value = SIGQUIT; break; + case SIGTERM: log_printf(NOTICE, "SIG-Term caught, exitting"); return_value = SIGTERM; break; + case SIGHUP: log_printf(NOTICE, "SIG-Hup caught"); return_value = SIGHUP; break; case SIGUSR1: log_printf(NOTICE, "SIG-Usr1 caught"); break; case SIGUSR2: log_printf(NOTICE, "SIG-Usr2 caught"); break; default: log_printf(WARNING, "unknown signal %d caught, ignoring", sig); break; diff --git a/src/uanytun.c b/src/uanytun.c index 159f773..da90eda 100644 --- a/src/uanytun.c +++ b/src/uanytun.c @@ -52,6 +52,10 @@ #include <stdio.h> #include <string.h> #include <errno.h> +#include <sys/select.h> +#include <sys/types.h> +#include <unistd.h> +#include <signal.h> #include "log.h" #include "sig_handler.h" @@ -258,9 +262,8 @@ int main_loop(tun_device_t* dev, udp_t* sock, options_t* opt) if(FD_ISSET(sig_fd, &readyfds)) { return_value = signal_handle(); - if(return_value == 1) - break; - else if(return_value == 2) { + if(return_value == SIGINT || return_value == SIGQUIT || return_value == SIGTERM) break; + else if(return_value == SIGHUP) { seq_win_clear(&seq_win); seq_nr = 0; log_printf(NOTICE, "sequence window cleared"); @@ -447,8 +450,11 @@ int main(int argc, char* argv[]) log_printf(NOTICE, "normal shutdown"); else if(ret < 0) log_printf(NOTICE, "shutdown after error"); - else + else { log_printf(NOTICE, "shutdown after signal"); + log_close(); + kill(getpid(), ret); + } log_close(); |