mirror of https://github.com/docker/compose.git
Forward all signals to child process
This commit is contained in:
parent
4dd1918ac2
commit
05a8582126
|
@ -21,6 +21,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"strings"
|
||||
|
||||
apicontext "github.com/docker/api/context"
|
||||
|
@ -61,6 +62,17 @@ func Exec() {
|
|||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
s := make(chan os.Signal)
|
||||
signal.Notify(s) // catch all signals
|
||||
go func() {
|
||||
for sig := range s {
|
||||
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())
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
if exiterr, ok := err.(*exec.ExitError); ok {
|
||||
os.Exit(exiterr.ExitCode())
|
||||
|
|
Loading…
Reference in New Issue