From 05a8582126280a0117d5f03a0106292ec43c1aef Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Wed, 5 Aug 2020 13:59:52 +0200 Subject: [PATCH] Forward all signals to child process --- cli/mobycli/exec.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/mobycli/exec.go b/cli/mobycli/exec.go index 179eb4a19..14a5f8b99 100644 --- a/cli/mobycli/exec.go +++ b/cli/mobycli/exec.go @@ -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())