mirror of https://github.com/docker/compose.git
Stop forwarding signals to child process when the child terminates
This commit is contained in:
parent
05a8582126
commit
29fe26620a
|
@ -62,18 +62,26 @@ func Exec() {
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
s := make(chan os.Signal)
|
signals := make(chan os.Signal)
|
||||||
signal.Notify(s) // catch all signals
|
childExit := make(chan bool)
|
||||||
|
signal.Notify(signals) // catch all signals
|
||||||
go func() {
|
go func() {
|
||||||
for sig := range s {
|
for {
|
||||||
err := cmd.Process.Signal(sig)
|
select {
|
||||||
if err != nil {
|
case sig := <-signals:
|
||||||
fmt.Printf("WARNING could not forward signal %s to %s : %s\n", sig.String(), ComDockerCli, err.Error())
|
err := cmd.Process.Signal(sig)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("WARNING could not forward signal %s to %s : %s\n", sig.String(), ComDockerCli, err.Error())
|
||||||
|
}
|
||||||
|
case <-childExit:
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if err := cmd.Run(); err != nil {
|
err := cmd.Run()
|
||||||
|
childExit <- true
|
||||||
|
if err != nil {
|
||||||
if exiterr, ok := err.(*exec.ExitError); ok {
|
if exiterr, ok := err.(*exec.ExitError); ok {
|
||||||
os.Exit(exiterr.ExitCode())
|
os.Exit(exiterr.ExitCode())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue