From: Ferenc Wagner Date: Tue, 13 Jul 2010 12:51:45 +0000 (+0200) Subject: forward signals to the container init X-Git-Tag: lxc-0.7.2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3304a29eb234cf1e90c74f9444f4d4de98e3e3a;p=thirdparty%2Flxc.git forward signals to the container init Signed-off-by: Ferenc Wagner Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/start.c b/src/lxc/start.c index dc57bea8e..92f44e3d2 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -195,13 +195,13 @@ static int setup_sigchld_fd(sigset_t *oldmask) sigset_t mask; int fd; - if (sigprocmask(SIG_BLOCK, NULL, &mask)) { - SYSERROR("failed to get mask signal"); - return -1; - } - - if (sigaddset(&mask, SIGCHLD) || sigprocmask(SIG_BLOCK, &mask, oldmask)) { - SYSERROR("failed to set mask signal"); + /* Block everything except serious error signals */ + if (sigfillset(&mask) || + sigdelset(&mask, SIGILL) || + sigdelset(&mask, SIGSEGV) || + sigdelset(&mask, SIGBUS) || + sigprocmask(SIG_BLOCK, &mask, oldmask)) { + SYSERROR("failed to set signal mask"); return -1; } @@ -231,7 +231,7 @@ static int sigchld_handler(int fd, void *data, ret = read(fd, &siginfo, sizeof(siginfo)); if (ret < 0) { - ERROR("failed to read sigchld info"); + ERROR("failed to read signal info"); return -1; } @@ -240,6 +240,12 @@ static int sigchld_handler(int fd, void *data, return -1; } + if (siginfo.ssi_signo != SIGCHLD) { + kill(*pid, siginfo.ssi_signo); + INFO("forwarded signal %d to pid %d", siginfo.ssi_signo, *pid); + return 0; + } + if (siginfo.ssi_code == CLD_STOPPED || siginfo.ssi_code == CLD_CONTINUED) { INFO("container init process was stopped/continued");