Skip to content

Commit

Permalink
Merge pull request #4192 from lifubang/feat-ClosePipeInExec
Browse files Browse the repository at this point in the history
Close sync pipe explicitly in exec
  • Loading branch information
kolyshkin authored Feb 8, 2024
2 parents 0212048 + bc4a869 commit 7c004d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions libcontainer/setns_init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"* ]]
}

0 comments on commit 7c004d8

Please sign in to comment.