Merge pull request #6030 from erikh/5971-fix-zombies

Add Wait() calls in the appropriate spots
This commit is contained in:
Michael Crosby 2014-05-27 12:53:17 -07:00
commit 88cefe20b4
5 changed files with 11 additions and 2 deletions

View File

@ -584,6 +584,7 @@ func (container *Container) Stop(seconds int) error {
log.Printf("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds) log.Printf("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds)
// 3. If it doesn't, then send SIGKILL // 3. If it doesn't, then send SIGKILL
if err := container.Kill(); err != nil { if err := container.Kill(); err != nil {
container.Wait()
return err return err
} }
} }

View File

@ -181,6 +181,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
if err != nil { if err != nil {
if c.Process != nil { if c.Process != nil {
c.Process.Kill() c.Process.Kill()
c.Process.Wait()
} }
return -1, err return -1, err
} }

View File

@ -40,6 +40,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str
} }
command := createCommand(container, console, rootfs, dataPath, os.Args[0], syncPipe.child, args) command := createCommand(container, console, rootfs, dataPath, os.Args[0], syncPipe.child, args)
if err := term.Attach(command); err != nil { if err := term.Attach(command); err != nil {
return -1, err return -1, err
} }
@ -55,6 +56,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str
} }
if err := WritePid(dataPath, command.Process.Pid, started); err != nil { if err := WritePid(dataPath, command.Process.Pid, started); err != nil {
command.Process.Kill() command.Process.Kill()
command.Process.Wait()
return -1, err return -1, err
} }
defer DeletePid(dataPath) defer DeletePid(dataPath)
@ -64,6 +66,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str
cleaner, err := SetupCgroups(container, command.Process.Pid) cleaner, err := SetupCgroups(container, command.Process.Pid)
if err != nil { if err != nil {
command.Process.Kill() command.Process.Kill()
command.Process.Wait()
return -1, err return -1, err
} }
if cleaner != nil { if cleaner != nil {
@ -72,6 +75,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str
if err := InitializeNetworking(container, command.Process.Pid, syncPipe); err != nil { if err := InitializeNetworking(container, command.Process.Pid, syncPipe); err != nil {
command.Process.Kill() command.Process.Kill()
command.Process.Wait()
return -1, err return -1, err
} }

View File

@ -126,7 +126,9 @@ func RestoreParentDeathSignal(old int) error {
// Signal self if parent is already dead. Does nothing if running in a new // Signal self if parent is already dead. Does nothing if running in a new
// PID namespace, as Getppid will always return 0. // PID namespace, as Getppid will always return 0.
if syscall.Getppid() == 1 { if syscall.Getppid() == 1 {
return syscall.Kill(syscall.Getpid(), syscall.Signal(old)) err := syscall.Kill(syscall.Getpid(), syscall.Signal(old))
syscall.Wait4(syscall.Getpid(), nil, 0, nil)
return err
} }
return nil return nil

View File

@ -28,10 +28,11 @@ func (t *TtyTerminal) Attach(command *exec.Cmd) error {
go io.Copy(t.master, t.stdin) go io.Copy(t.master, t.stdin)
state, err := t.setupWindow(t.master, os.Stdin) state, err := t.setupWindow(t.master, os.Stdin)
if err != nil { if err != nil {
command.Process.Kill()
return err return err
} }
t.state = state t.state = state
return err return err
} }