minor cleanup for signal handling
This commit is contained in:
parent
88cb9f3116
commit
2ba5c91547
11
commands.go
11
commands.go
|
@ -1396,13 +1396,10 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
||||||
signals := make(chan os.Signal, 1)
|
signals := make(chan os.Signal, 1)
|
||||||
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for sig := range signals {
|
||||||
sig := <-signals
|
fmt.Printf("\nReceived signal: %s; cleaning up\n", sig)
|
||||||
if sig == syscall.SIGINT || sig == syscall.SIGTERM {
|
if err := cli.CmdStop("-t", "4", runResult.ID); err != nil {
|
||||||
fmt.Printf("\nReceived signal: %s; cleaning up\n", sig)
|
fmt.Printf("failed to stop container:", err)
|
||||||
if err := cli.CmdStop("-t", "4", runResult.ID); err != nil {
|
|
||||||
fmt.Printf("failed to stop container:", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in New Issue