On Thu, Jan 16, 2014 at 03:05:46PM -0500, S.Çağlar Onur wrote: > Hey, > > On Thu, Jan 16, 2014 at 11:03 AM, Stéphane Graber <stgra...@ubuntu.com> wrote: > > On Thu, Jan 16, 2014 at 03:30:01PM +0800, Qiang Huang wrote: > >> Look through all LXC code and seems like only here are missed. > >> > >> Signed-off-by: Qiang Huang <h.huangqi...@huawei.com> > > > > Acked-by: Stéphane Graber <stgra...@ubuntu.com> > > Looks like lxc-execute stopped working after this patch > > [caglar@qp:~/go/src/github.com/caglar10ur/lxc(devel)] sudo lxc-execute > -n t -- ls > lxc-init: Invalid argument - failed to sigaction > > reverting the commit makes it functional again > > [caglar@qp:~/go/src/github.com/caglar10ur/lxc(devel)] sudo lxc-execute > -n t -- ls > LICENSE Makefile README.md const.go container.go examples lxc.c > lxc.go lxc.h lxc_test.go type.go util.go
Interesting, can we try to figure out what sig handler is failing, I believe that'd be more interesting than doing a plain revert as the intent of the previous commit still seems good. > > >> --- > >> Maybe this bug can be marked resolved: > >> https://github.com/lxc/lxc/issues/83 > >> --- > >> src/lxc/lxc_init.c | 46 +++++++++++++++++++++++++++++++--------------- > >> 1 file changed, 31 insertions(+), 15 deletions(-) > >> > >> diff --git a/src/lxc/lxc_init.c b/src/lxc/lxc_init.c > >> index d88a935..a59dd9c 100644 > >> --- a/src/lxc/lxc_init.c > >> +++ b/src/lxc/lxc_init.c > >> @@ -123,11 +123,14 @@ int main(int argc, char *argv[]) > >> * mask all the signals so we are safe to install a > >> * signal handler and to fork > >> */ > >> - sigfillset(&mask); > >> - sigdelset(&mask, SIGILL); > >> - sigdelset(&mask, SIGSEGV); > >> - sigdelset(&mask, SIGBUS); > >> - sigprocmask(SIG_SETMASK, &mask, &omask); > >> + if (sigfillset(&mask) || > >> + sigdelset(&mask, SIGILL) || > >> + sigdelset(&mask, SIGSEGV) || > >> + sigdelset(&mask, SIGBUS) || > >> + sigprocmask(SIG_SETMASK, &mask, &omask)) { > >> + SYSERROR("failed to set signal mask"); > >> + exit(EXIT_FAILURE); > >> + } > >> > >> for (i = 1; i < NSIG; i++) { > >> struct sigaction act; > >> @@ -143,15 +146,22 @@ int main(int argc, char *argv[]) > >> i == SIGKILL) > >> continue; > >> > >> - sigfillset(&act.sa_mask); > >> - sigdelset(&act.sa_mask, SIGILL); > >> - sigdelset(&act.sa_mask, SIGSEGV); > >> - sigdelset(&act.sa_mask, SIGBUS); > >> - sigdelset(&act.sa_mask, SIGSTOP); > >> - sigdelset(&act.sa_mask, SIGKILL); > >> + if (sigfillset(&act.sa_mask) || > >> + sigdelset(&act.sa_mask, SIGILL) || > >> + sigdelset(&act.sa_mask, SIGSEGV) || > >> + sigdelset(&act.sa_mask, SIGBUS) || > >> + sigdelset(&act.sa_mask, SIGSTOP) || > >> + sigdelset(&act.sa_mask, SIGKILL)) { > >> + ERROR("failed to set signal"); > >> + exit(EXIT_FAILURE); > >> + } > >> + > >> act.sa_flags = 0; > >> act.sa_handler = interrupt_handler; > >> - sigaction(i, &act, NULL); > >> + if (sigaction(i, &act, NULL)) { > >> + SYSERROR("failed to sigaction"); > >> + exit(EXIT_FAILURE); > >> + } > >> } > >> > >> lxc_setup_fs(); > >> @@ -170,7 +180,10 @@ int main(int argc, char *argv[]) > >> for (i = 1; i < NSIG; i++) > >> signal(i, SIG_DFL); > >> > >> - sigprocmask(SIG_SETMASK, &omask, NULL); > >> + if (sigprocmask(SIG_SETMASK, &omask, NULL)) { > >> + SYSERROR("failed to set signal mask"); > >> + exit(EXIT_FAILURE); > >> + } > >> > >> NOTICE("about to exec '%s'", aargv[0]); > >> > >> @@ -180,8 +193,11 @@ int main(int argc, char *argv[]) > >> } > >> > >> /* let's process the signals now */ > >> - sigdelset(&omask, SIGALRM); > >> - sigprocmask(SIG_SETMASK, &omask, NULL); > >> + if (sigdelset(&omask, SIGALRM) || > >> + sigprocmask(SIG_SETMASK, &omask, NULL)) { > >> + SYSERROR("failed to set signal mask"); > >> + exit(EXIT_FAILURE); > >> + } > >> > >> /* no need of other inherited fds but stderr */ > >> close(fileno(stdin)); > >> -- > >> 1.8.3 > >> > > > > -- > > Stéphane Graber > > Ubuntu developer > > http://www.ubuntu.com > > > > _______________________________________________ > > lxc-devel mailing list > > lxc-devel@lists.linuxcontainers.org > > http://lists.linuxcontainers.org/listinfo/lxc-devel > > > > > > -- > S.Çağlar Onur <cag...@10ur.org> > _______________________________________________ > lxc-devel mailing list > lxc-devel@lists.linuxcontainers.org > http://lists.linuxcontainers.org/listinfo/lxc-devel -- Stéphane Graber Ubuntu developer http://www.ubuntu.com
signature.asc
Description: Digital signature
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel