Add Wait() calls in the appropriate spots
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
parent
4a0d1718ee
commit
36bd5bf98b
2 changed files with 8 additions and 1 deletions
|
@ -40,7 +40,9 @@ 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 {
|
||||||
|
command.Wait()
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
defer term.Close()
|
defer term.Close()
|
||||||
|
@ -55,6 +57,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 +67,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 +76,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue