Set child sub reaper option on nsenter to help cleanup all processes orphaned via ExecIn.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
Vishnu Kannan 2014-11-19 20:14:20 +00:00
parent 101dff031b
commit 4c6df516ae
1 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/prctl.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <getopt.h> #include <getopt.h>
@ -88,6 +89,11 @@ void nsenter()
return; return;
} }
if (prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0) == -1) {
fprintf(stderr, "nsenter: failed to set child subreaper: %s", strerror(errno));
exit(1);
}
static const struct option longopts[] = { static const struct option longopts[] = {
{"nspid", required_argument, NULL, 'n'}, {"nspid", required_argument, NULL, 'n'},
{"console", required_argument, NULL, 't'}, {"console", required_argument, NULL, 't'},