diff --git a/libcontainer/setns_init_linux.go b/libcontainer/setns_init_linux.go index 4a458fcbeba..ba48604d988 100644 --- a/libcontainer/setns_init_linux.go +++ b/libcontainer/setns_init_linux.go @@ -129,6 +129,11 @@ func (l *linuxSetnsInit) Init() error { } } + // Close the pipe to signal that we have completed our init. + // Please keep this because we don't want to get a pipe write error if + // there is an error from `execve` after all fds closed. + _ = l.pipe.Close() + // Close the log pipe fd so the parent's ForwardLogs can exit. logrus.Debugf("setns_init: about to exec") if err := l.logPipe.Close(); err != nil { diff --git a/tests/integration/exec.bats b/tests/integration/exec.bats index 78f922d04b4..2809070486e 100644 --- a/tests/integration/exec.bats +++ b/tests/integration/exec.bats @@ -338,5 +338,5 @@ EOF # Although we never close the sync socket when doing exec, # but we need to keep this test to ensure this behavior is always right. [ ${#lines[@]} -eq 1 ] - [[ ${lines[0]} = *"exec failed: unable to start container process: exec /run.sh: no such file or directory"* ]] + [[ ${lines[0]} = *"exec /run.sh: no such file or directory"* ]] }