X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=door_daemon%2Fsig_handler.c;h=55fe5565a99a92b4fb8fb15f64308ff6f27c64b3;hb=33bf0f0f0aa1a480ffa4ffff311af196ee1067c1;hp=7a1ad745c3e720c4f9513b162924b7136ef8a7c2;hpb=bd2c78928d653160ef85e25e03e8b4e721635ac6;p=svn42.git diff --git a/door_daemon/sig_handler.c b/door_daemon/sig_handler.c index 7a1ad74..55fe556 100644 --- a/door_daemon/sig_handler.c +++ b/door_daemon/sig_handler.c @@ -20,8 +20,9 @@ * This file is part of uAnytun. * * uAnytun is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3 as - * published by the Free Software Foundation. + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. * * uAnytun is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -81,17 +82,22 @@ int signal_init() } } - struct sigaction act; + struct sigaction act, ign; act.sa_handler = sig_handler; sigfillset(&act.sa_mask); act.sa_flags = 0; + ign.sa_handler = SIG_IGN; + sigfillset(&ign.sa_mask); + ign.sa_flags = 0; if((sigaction(SIGINT, &act, NULL) < 0) || (sigaction(SIGQUIT, &act, NULL) < 0) || (sigaction(SIGTERM, &act, NULL) < 0) || (sigaction(SIGHUP, &act, NULL) < 0) || (sigaction(SIGUSR1, &act, NULL) < 0) || - (sigaction(SIGUSR2, &act, NULL) < 0)) { + (sigaction(SIGUSR2, &act, NULL) < 0) || + (sigaction(SIGCHLD, &ign, NULL) < 0) || + (sigaction(SIGPIPE, &ign, NULL) < 0)) { log_printf(ERROR, "signal handling init failed (sigaction error: %s)", strerror(errno)); close(sig_pipe_fds[0]); @@ -120,7 +126,7 @@ int signal_handle() int return_value = 0; int sig; - for(sig=1; sig < _NSIG; ++sig) { + 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; @@ -152,6 +158,8 @@ void signal_stop() sigaction(SIGHUP, &act, NULL); sigaction(SIGUSR1, &act, NULL); sigaction(SIGUSR2, &act, NULL); + sigaction(SIGPIPE, &act, NULL); + sigaction(SIGCHLD, &act, NULL); close(sig_pipe_fds[0]); close(sig_pipe_fds[1]);