mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #20934 from icecrime/20543_debugging
Fix race condition on daemon shutdown (#20543)
This commit is contained in:
commit
2af84d8875
1 changed files with 7 additions and 4 deletions
|
@ -157,6 +157,10 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
|
|||
if err != nil {
|
||||
return execdriver.ExitStatus{ExitCode: -1}, err
|
||||
}
|
||||
|
||||
if err := cont.Start(p); err != nil {
|
||||
return execdriver.ExitStatus{ExitCode: -1}, err
|
||||
}
|
||||
d.Lock()
|
||||
d.activeContainers[c.ID] = cont
|
||||
d.Unlock()
|
||||
|
@ -167,10 +171,6 @@ func (d *Driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, hooks execd
|
|||
d.cleanContainer(c.ID)
|
||||
}()
|
||||
|
||||
if err := cont.Start(p); err != nil {
|
||||
return execdriver.ExitStatus{ExitCode: -1}, err
|
||||
}
|
||||
|
||||
//close the write end of any opened pipes now that they are dup'ed into the container
|
||||
for _, writer := range writers {
|
||||
writer.Close()
|
||||
|
@ -302,6 +302,9 @@ func (d *Driver) Kill(c *execdriver.Command, sig int) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if state.InitProcessPid == -1 {
|
||||
return fmt.Errorf("avoid sending signal %d to container %s with pid -1", sig, c.ID)
|
||||
}
|
||||
return syscall.Kill(state.InitProcessPid, syscall.Signal(sig))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue