fix signals

This commit is contained in:
Shane C 2024-07-11 17:27:44 -04:00
parent 8959b13a0d
commit b14e2ccfb1
Signed by: shane
GPG key ID: E46B5FEA35B22FF9

View file

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