From 61338577b58e3b5f41475c7052bfb1ff04d27325 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Mon, 19 Sep 2016 13:34:05 -0700 Subject: [PATCH] Notify containerd of init death before waiting for children in shim Signed-off-by: Kenfe-Mickael Laventure --- containerd-shim/main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/containerd-shim/main.go b/containerd-shim/main.go index 85d5f1e..0d69363 100644 --- a/containerd-shim/main.go +++ b/containerd-shim/main.go @@ -117,11 +117,17 @@ func start(log *os.File) error { } // runtime has exited so the shim can also exit if exitShim { - // Wait for all the childs this process may have created - // (only needed for exec, but it won't hurt when done on init) - osutils.Reap(true) - // Let containerd take care of calling the runtime delete + // Let containerd take care of calling the runtime + // delete. + // This is needed to be done first in order to ensure + // that the call to Reap does not block until all + // children of the container have died if init was not + // started in its own PID namespace. f.Close() + // Wait for all the childs this process may have + // created (needed for exec and init processes when + // they join another pid namespace) + osutils.Reap(true) p.Wait() return nil }