Skip to content

Commit 7c004d8

Browse files
authored
Merge pull request #4192 from lifubang/feat-ClosePipeInExec
Close sync pipe explicitly in exec
2 parents 0212048 + bc4a869 commit 7c004d8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

libcontainer/setns_init_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ func (l *linuxSetnsInit) Init() error {
129129
}
130130
}
131131

132+
// Close the pipe to signal that we have completed our init.
133+
// Please keep this because we don't want to get a pipe write error if
134+
// there is an error from `execve` after all fds closed.
135+
_ = l.pipe.Close()
136+
132137
// Close the log pipe fd so the parent's ForwardLogs can exit.
133138
logrus.Debugf("setns_init: about to exec")
134139
if err := l.logPipe.Close(); err != nil {

tests/integration/exec.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,5 +338,5 @@ EOF
338338
# Although we never close the sync socket when doing exec,
339339
# but we need to keep this test to ensure this behavior is always right.
340340
[ ${#lines[@]} -eq 1 ]
341-
[[ ${lines[0]} = *"exec failed: unable to start container process: exec /run.sh: no such file or directory"* ]]
341+
[[ ${lines[0]} = *"exec /run.sh: no such file or directory"* ]]
342342
}

0 commit comments

Comments
 (0)