From eab53309089c388aa35e8531f95a3c073f6bc0d5 Mon Sep 17 00:00:00 2001 From: Alex Fang Date: Thu, 21 Mar 2019 13:24:04 +1100 Subject: [PATCH] Fixes regression causing zombie runc:[1:CHILD] processes Whenever processes are spawned using nsexec, a zombie runc:[1:CHILD] process will always be created and will need to be reaped by the parent Signed-off-by: Alex Fang --- libcontainer/process_linux.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go index e8ffac9fa58..6507f0e6968 100644 --- a/libcontainer/process_linux.go +++ b/libcontainer/process_linux.go @@ -158,10 +158,8 @@ func (p *setnsProcess) execSetns() error { } // Clean up the zombie parent process - firstChildProcess, err := os.FindProcess(pid.PidFirstChild) - if err != nil { - return err - } + // On Unix systems FindProcess always succeeds. + firstChildProcess, _ := os.FindProcess(pid.PidFirstChild) // Ignore the error in case the child has already been reaped for any reason _, _ = firstChildProcess.Wait() @@ -236,6 +234,14 @@ func (p *initProcess) getChildPid() (int, error) { p.cmd.Wait() return -1, err } + + // Clean up the zombie parent process + // On Unix systems FindProcess always succeeds. + firstChildProcess, _ := os.FindProcess(pid.PidFirstChild) + + // Ignore the error in case the child has already been reaped for any reason + _, _ = firstChildProcess.Wait() + return pid.Pid, nil }