Skip to content

Commit

Permalink
merge opencontainers#4647 into opencontainers/runc:release-1.2
Browse files Browse the repository at this point in the history
Evan Phoenix (1):
  libcontainer: Prevent startup hang when CloseExecFrom errors

LGTMs: lifubang cyphar
  • Loading branch information
cyphar committed Feb 27, 2025
2 parents 35d1d6e + e643905 commit 4dbf9ac
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,6 @@ func (c *Container) start(process *Process) (retErr error) {
defer process.closeClonedExes()

logsDone := parent.forwardChildLogs()
if logsDone != nil {
defer func() {
// Wait for log forwarder to finish. This depends on
// runc init closing the _LIBCONTAINER_LOGPIPE log fd.
err := <-logsDone
if err != nil && retErr == nil {
retErr = fmt.Errorf("unable to forward init logs: %w", err)
}
}()
}

// Before starting "runc init", mark all non-stdio open files as O_CLOEXEC
// to make sure we don't leak any files into "runc init". Any files to be
Expand All @@ -348,6 +338,17 @@ func (c *Container) start(process *Process) (retErr error) {
return fmt.Errorf("unable to start container process: %w", err)
}

if logsDone != nil {
defer func() {
// Wait for log forwarder to finish. This depends on
// runc init closing the _LIBCONTAINER_LOGPIPE log fd.
err := <-logsDone
if err != nil && retErr == nil {
retErr = fmt.Errorf("unable to forward init logs: %w", err)
}
}()
}

if process.Init {
c.fifo.Close()
if c.config.Hooks != nil {
Expand Down

0 comments on commit 4dbf9ac

Please sign in to comment.