From b9de22e82860a7e389f356d349ccb61b7d530c54 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 27 May 2014 13:38:24 -0700 Subject: [PATCH 1/2] Update wait calls to call Wait on Command Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- pkg/libcontainer/nsinit/exec.go | 6 +++--- pkg/libcontainer/nsinit/init.go | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/libcontainer/nsinit/exec.go b/pkg/libcontainer/nsinit/exec.go index 0813470a90..f266303f8c 100644 --- a/pkg/libcontainer/nsinit/exec.go +++ b/pkg/libcontainer/nsinit/exec.go @@ -56,7 +56,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str } if err := WritePid(dataPath, command.Process.Pid, started); err != nil { command.Process.Kill() - command.Process.Wait() + command.Wait() return -1, err } defer DeletePid(dataPath) @@ -66,7 +66,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str cleaner, err := SetupCgroups(container, command.Process.Pid) if err != nil { command.Process.Kill() - command.Process.Wait() + command.Wait() return -1, err } if cleaner != nil { @@ -75,7 +75,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str if err := InitializeNetworking(container, command.Process.Pid, syncPipe); err != nil { command.Process.Kill() - command.Process.Wait() + command.Wait() return -1, err } diff --git a/pkg/libcontainer/nsinit/init.go b/pkg/libcontainer/nsinit/init.go index 509f3a2796..8139865a02 100644 --- a/pkg/libcontainer/nsinit/init.go +++ b/pkg/libcontainer/nsinit/init.go @@ -126,9 +126,7 @@ func RestoreParentDeathSignal(old int) error { // Signal self if parent is already dead. Does nothing if running in a new // PID namespace, as Getppid will always return 0. if syscall.Getppid() == 1 { - err := syscall.Kill(syscall.Getpid(), syscall.Signal(old)) - syscall.Wait4(syscall.Getpid(), nil, 0, nil) - return err + return syscall.Kill(syscall.Getpid(), syscall.SIGKILL) } return nil From 5310e8575f5a251000bbecd6d998eb11cb95fe04 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 27 May 2014 13:52:05 -0700 Subject: [PATCH 2/2] Update lxc to use cmd.Wait() Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- daemon/execdriver/lxc/driver.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/execdriver/lxc/driver.go b/daemon/execdriver/lxc/driver.go index 2e84fcc84d..54f1054191 100644 --- a/daemon/execdriver/lxc/driver.go +++ b/daemon/execdriver/lxc/driver.go @@ -167,6 +167,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba waitErr error waitLock = make(chan struct{}) ) + go func() { if err := c.Wait(); err != nil { if _, ok := err.(*exec.ExitError); !ok { // Do not propagate the error if it's simply a status code != 0 @@ -181,10 +182,11 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba if err != nil { if c.Process != nil { c.Process.Kill() - c.Process.Wait() + c.Wait() } return -1, err } + c.ContainerPid = pid if startCallback != nil {