diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2019-01-29 23:07:35 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2019-01-29 23:14:35 -0500 |
| commit | 6ea09ce6af26de5e6e9bfc3849e9f2b90c80428d (patch) | |
| tree | 099b6806e4b4a567ed0880846682daee043987bb /cmd/gomplate/main.go | |
| parent | b2240e21bec4362aa8aedfcef5637a6c2a60d058 (diff) | |
Propagate signals to post-run processes
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'cmd/gomplate/main.go')
| -rw-r--r-- | cmd/gomplate/main.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd/gomplate/main.go b/cmd/gomplate/main.go index 46c4dfa5..20b1e5a2 100644 --- a/cmd/gomplate/main.go +++ b/cmd/gomplate/main.go @@ -9,6 +9,7 @@ import ( "fmt" "os" "os/exec" + "os/signal" "github.com/hairyhenderson/gomplate" "github.com/hairyhenderson/gomplate/env" @@ -60,6 +61,21 @@ func postRunExec(cmd *cobra.Command, args []string) error { c.Stdin = os.Stdin c.Stderr = os.Stderr c.Stdout = os.Stdout + + // make sure all signals are propagated + sigs := make(chan os.Signal, 1) + signal.Notify(sigs) + go func() { + // Pass signals to the sub-process + select { + case sig := <-sigs: + if c.Process != nil { + // nolint: gosec + c.Process.Signal(sig) + } + } + }() + return c.Run() } return nil |
