From 2ba5c915473ce6fe769fb059db4120e2a21fb42e Mon Sep 17 00:00:00 2001 From: unclejack Date: Fri, 9 Aug 2013 23:23:27 +0300 Subject: [PATCH] minor cleanup for signal handling --- commands.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/commands.go b/commands.go index d045625c73..ffe4ce230e 100644 --- a/commands.go +++ b/commands.go @@ -1396,13 +1396,10 @@ func (cli *DockerCli) CmdRun(args ...string) error { signals := make(chan os.Signal, 1) signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) go func() { - for { - sig := <-signals - if sig == syscall.SIGINT || sig == syscall.SIGTERM { - fmt.Printf("\nReceived signal: %s; cleaning up\n", sig) - if err := cli.CmdStop("-t", "4", runResult.ID); err != nil { - fmt.Printf("failed to stop container:", err) - } + for sig := range signals { + fmt.Printf("\nReceived signal: %s; cleaning up\n", sig) + if err := cli.CmdStop("-t", "4", runResult.ID); err != nil { + fmt.Printf("failed to stop container:", err) } } }()