start: signal_handler()

parent 70703881
...@@ -304,13 +304,13 @@ static int signal_handler(int fd, uint32_t events, void *data, ...@@ -304,13 +304,13 @@ static int signal_handler(int fd, uint32_t events, void *data,
ret = read(fd, &siginfo, sizeof(siginfo)); ret = read(fd, &siginfo, sizeof(siginfo));
if (ret < 0) { if (ret < 0) {
ERROR("Failed to read signal info from signal file descriptor: %d.", fd); ERROR("Failed to read signal info from signal file descriptor %d", fd);
return -1; return -1;
} }
if (ret != sizeof(siginfo)) { if (ret != sizeof(siginfo)) {
ERROR("Unexpected size for siginfo struct."); ERROR("Unexpected size for struct signalfd_siginfo");
return -1; return -EINVAL;
} }
/* Check whether init is running. */ /* Check whether init is running. */
...@@ -351,25 +351,26 @@ static int signal_handler(int fd, uint32_t events, void *data, ...@@ -351,25 +351,26 @@ static int signal_handler(int fd, uint32_t events, void *data,
* by a process different from the container init. * by a process different from the container init.
*/ */
if (siginfo.ssi_pid != hdlr->pid) { if (siginfo.ssi_pid != hdlr->pid) {
NOTICE("Received %d from pid %d instead of container init %d.", siginfo.ssi_signo, siginfo.ssi_pid, hdlr->pid); NOTICE("Received %d from pid %d instead of container init %d",
siginfo.ssi_signo, siginfo.ssi_pid, hdlr->pid);
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0; return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
} }
if (siginfo.ssi_signo != SIGCHLD) { if (siginfo.ssi_signo != SIGCHLD) {
kill(hdlr->pid, siginfo.ssi_signo); kill(hdlr->pid, siginfo.ssi_signo);
INFO("Forwarded signal %d to pid %d.", siginfo.ssi_signo, hdlr->pid); INFO("Forwarded signal %d to pid %d", siginfo.ssi_signo, hdlr->pid);
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0; return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
} }
if (siginfo.ssi_code == CLD_STOPPED) { if (siginfo.ssi_code == CLD_STOPPED) {
INFO("Container init process was stopped."); INFO("Container init process was stopped");
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0; return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
} else if (siginfo.ssi_code == CLD_CONTINUED) { } else if (siginfo.ssi_code == CLD_CONTINUED) {
INFO("Container init process was continued."); INFO("Container init process was continued");
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0; return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
} }
DEBUG("Container init process %d exited.", hdlr->pid); DEBUG("Container init process %d exited", hdlr->pid);
return LXC_MAINLOOP_CLOSE; return LXC_MAINLOOP_CLOSE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment