Skip to content

Commit

Permalink
Simplify process scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
bitflipp committed Jul 18, 2024
1 parent 7d8c5c3 commit f341b4f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions internal/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,12 @@ func (r *rule) processScanner(name string, args ...string) (chan *match, error)
if cmd.Process != nil {
cmd.Process.Signal(os.Interrupt)
time.Sleep(5 * time.Second)
select {
case <-stop:
default:
cmd.Process.Kill()
}
cmd.Process.Kill()
}
}()

c := make(chan *match, 1)
go func() {
defer func() {
stop <- true
close(stop)
}()

rcs := []io.ReadCloser{o, e}
wg := &sync.WaitGroup{}
wg.Add(len(rcs))
Expand All @@ -285,6 +276,7 @@ func (r *rule) processScanner(name string, args ...string) (chan *match, error)
log.Warn().Str("rule", r.name).Str("command", cmd.String()).Err(err).Msg("failed to scan command output")
}
wg.Done()
stop <- true
}(rc)
}
wg.Wait()
Expand Down

0 comments on commit f341b4f

Please sign in to comment.