Send sigterm and wait forever

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
Upstream-commit: 93779cc7fee4ee0690d9dd28eed478a418e79577
Component: engine
This commit is contained in:
Michael Crosby
2014-04-01 07:12:50 +00:00
parent 8169d6ecd6
commit 2ec7753394
2 changed files with 8 additions and 4 deletions
-1
View File
@@ -915,7 +915,6 @@ func (container *Container) Stop(seconds int) error {
// 1. Send a SIGTERM
if err := container.KillSig(15); err != nil {
utils.Debugf("Error sending kill SIGTERM: %s", err)
log.Print("Failed to send SIGTERM to the process, force killing")
if err := container.KillSig(9); err != nil {
return err
+8 -3
View File
@@ -797,13 +797,18 @@ func (runtime *Runtime) shutdown() error {
group := sync.WaitGroup{}
utils.Debugf("starting clean shutdown of all containers...")
for _, container := range runtime.List() {
if container.State.IsRunning() {
utils.Debugf("stopping %s", container.ID)
c := container
if c.State.IsRunning() {
utils.Debugf("stopping %s", c.ID)
group.Add(1)
go func() {
defer group.Done()
container.Stop(10)
if err := c.KillSig(15); err != nil {
utils.Debugf("kill 15 error for %s - %s", c.ID, err)
}
c.Wait()
utils.Debugf("container stopped %s", c.ID)
}()
}
}