diff --git a/pkg/security/tests/trace_pipe.go b/pkg/security/tests/trace_pipe.go index e28a72cd9f3ab..973c03f1023ea 100644 --- a/pkg/security/tests/trace_pipe.go +++ b/pkg/security/tests/trace_pipe.go @@ -117,9 +117,19 @@ func (t *TracePipe) Channel() (<-chan *TraceEvent, <-chan error) { if err == io.EOF { continue } - channelErrors <- err + select { + case <-t.stop: + return + case channelErrors <- err: + // do nothing + } } else { - channelEvents <- traceEvent + select { + case <-t.stop: + return + case channelEvents <- traceEvent: + // do nothing + } } } }()