Skip to content

Commit

Permalink
Merge pull request #2130 from tych0/sigterm-handling
Browse files Browse the repository at this point in the history
Sigterm handling
  • Loading branch information
hallyn committed Feb 5, 2018
2 parents 05f2fed + 186dfb1 commit af3f9cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lxc/lxc_init.c
Expand Up @@ -382,6 +382,17 @@ int main(int argc, char *argv[])

switch (was_interrupted) {
case 0:
/* Some applications send SIGHUP in order to get init to reload
* its configuration. We don't want to forward this onto the
* application itself, because it probably isn't expecting this
* signal since it was expecting init to do something with it.
*
* Instead, let's explicitly ignore it here. The actual
* terminal case is handled in the monitor's handler, which
* sends this task a SIGTERM in the case of a SIGHUP, which is
* what we want.
*/
case SIGHUP:
break;
case SIGPWR:
case SIGTERM:
Expand Down
6 changes: 6 additions & 0 deletions src/lxc/start.c
Expand Up @@ -345,6 +345,12 @@ static int signal_handler(int fd, uint32_t events, void *data,
}
}

if (siginfo.ssi_signo == SIGHUP) {
kill(hdlr->pid, SIGTERM);
INFO("Killing %d since terminal hung up", hdlr->pid);
return hdlr->init_died ? LXC_MAINLOOP_CLOSE : 0;
}

/* More robustness, protect ourself from a SIGCHLD sent
* by a process different from the container init.
*/
Expand Down

0 comments on commit af3f9cc

Please sign in to comment.