Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
| ... | ... |
@@ -584,6 +584,7 @@ func (container *Container) Stop(seconds int) error {
|
| 584 | 584 |
log.Printf("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds)
|
| 585 | 585 |
// 3. If it doesn't, then send SIGKILL |
| 586 | 586 |
if err := container.Kill(); err != nil {
|
| 587 |
+ container.Wait() |
|
| 587 | 588 |
return err |
| 588 | 589 |
} |
| 589 | 590 |
} |
| ... | ... |
@@ -40,7 +40,9 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str |
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
command := createCommand(container, console, rootfs, dataPath, os.Args[0], syncPipe.child, args) |
| 43 |
+ |
|
| 43 | 44 |
if err := term.Attach(command); err != nil {
|
| 45 |
+ command.Wait() |
|
| 44 | 46 |
return -1, err |
| 45 | 47 |
} |
| 46 | 48 |
defer term.Close() |
| ... | ... |
@@ -55,6 +57,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str |
| 55 | 55 |
} |
| 56 | 56 |
if err := WritePid(dataPath, command.Process.Pid, started); err != nil {
|
| 57 | 57 |
command.Process.Kill() |
| 58 |
+ command.Process.Wait() |
|
| 58 | 59 |
return -1, err |
| 59 | 60 |
} |
| 60 | 61 |
defer DeletePid(dataPath) |
| ... | ... |
@@ -64,6 +67,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str |
| 64 | 64 |
cleaner, err := SetupCgroups(container, command.Process.Pid) |
| 65 | 65 |
if err != nil {
|
| 66 | 66 |
command.Process.Kill() |
| 67 |
+ command.Process.Wait() |
|
| 67 | 68 |
return -1, err |
| 68 | 69 |
} |
| 69 | 70 |
if cleaner != nil {
|
| ... | ... |
@@ -72,6 +76,7 @@ func Exec(container *libcontainer.Container, term Terminal, rootfs, dataPath str |
| 72 | 72 |
|
| 73 | 73 |
if err := InitializeNetworking(container, command.Process.Pid, syncPipe); err != nil {
|
| 74 | 74 |
command.Process.Kill() |
| 75 |
+ command.Process.Wait() |
|
| 75 | 76 |
return -1, err |
| 76 | 77 |
} |
| 77 | 78 |
|
| ... | ... |
@@ -126,7 +126,9 @@ func RestoreParentDeathSignal(old int) error {
|
| 126 | 126 |
// Signal self if parent is already dead. Does nothing if running in a new |
| 127 | 127 |
// PID namespace, as Getppid will always return 0. |
| 128 | 128 |
if syscall.Getppid() == 1 {
|
| 129 |
- return syscall.Kill(syscall.Getpid(), syscall.Signal(old)) |
|
| 129 |
+ err := syscall.Kill(syscall.Getpid(), syscall.Signal(old)) |
|
| 130 |
+ syscall.Wait4(syscall.Getpid(), nil, 0, nil) |
|
| 131 |
+ return err |
|
| 130 | 132 |
} |
| 131 | 133 |
|
| 132 | 134 |
return nil |