Commit 6fd1668e by Daniel Lezcano

lxc-init kills all processes with SIGTERM

When lxc-init receives a SIGTERM, let's kill all the processes of the pid namespace with kill -1. So the exit of the container will happen gracefully with processes death cascade. Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 83ee7875
...@@ -154,11 +154,21 @@ int main(int argc, char *argv[]) ...@@ -154,11 +154,21 @@ int main(int argc, char *argv[])
int orphan = 0; int orphan = 0;
pid_t waited_pid; pid_t waited_pid;
if (was_interrupted) { switch (was_interrupted) {
case 0:
break;
case SIGTERM:
kill(-1, SIGTERM);
break;
default:
kill(pid, was_interrupted); kill(pid, was_interrupted);
was_interrupted = 0; break;
} }
was_interrupted = 0;
waited_pid = wait(&status); waited_pid = wait(&status);
if (waited_pid < 0) { if (waited_pid < 0) {
if (errno == ECHILD) if (errno == ECHILD)
......
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