mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
Merge pull request #4599 from evanphx/evanphx/b-logs-hang
libcontainer: Prevent startup hang when CloseExecFrom errors
This commit is contained in:
@@ -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
|
||||
@@ -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.HasHook(configs.Poststart) {
|
||||
|
||||
Reference in New Issue
Block a user