From 4c6df516ae76a366f0ba34be8a50cbef62d83812 Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Wed, 19 Nov 2014 20:14:20 +0000 Subject: [PATCH] Set child sub reaper option on nsenter to help cleanup all processes orphaned via ExecIn. Docker-DCO-1.1-Signed-off-by: Vishnu Kannan (github: vishh) --- namespaces/nsenter/nsenter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/namespaces/nsenter/nsenter.c b/namespaces/nsenter/nsenter.c index 2869dd14..f060f63b 100644 --- a/namespaces/nsenter/nsenter.c +++ b/namespaces/nsenter/nsenter.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,11 @@ void nsenter() 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[] = { {"nspid", required_argument, NULL, 'n'}, {"console", required_argument, NULL, 't'},