From b14e2ccfb1a15e4aa828e6d43744776b248ca383 Mon Sep 17 00:00:00 2001 From: Shane C Date: Thu, 11 Jul 2024 17:27:44 -0400 Subject: [PATCH] fix signals --- linux/run.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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