minor cleanup for signal handling

This commit is contained in:
unclejack 2013-08-09 23:23:27 +03:00
parent 88cb9f3116
commit 2ba5c91547
1 changed files with 4 additions and 7 deletions

View File

@ -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)
}
}
}()