diff --git a/linux/run.go b/linux/run.go index cf31040..ad1c76d 100644 --- a/linux/run.go +++ b/linux/run.go @@ -84,11 +84,10 @@ func (cmd *LinuxCommand) Run() error { } var signalChannel chan os.Signal + signalChannel = make(chan os.Signal, 1) + signal.Notify(signalChannel, unix.SIGINT, unix.SIGTERM) if len(cmd.handlers) != 0 { - signalChannel = make(chan os.Signal, 1) - signal.Notify(signalChannel, unix.SIGINT, unix.SIGTERM) - var err error cmd.stdout, err = command.StdoutPipe() if err != nil { @@ -227,8 +226,8 @@ func (cmd *LinuxCommand) Run() error { } } - signal.Stop(signalChannel) close(signalChannel) + signal.Stop(signalChannel) cmd.wg.Wait() return nil