From d429ae3ea4964809e31db280ef0f1c8e10b58a48 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Wed, 31 Jul 2024 09:58:57 +0200 Subject: [PATCH] [CWS] make sure we check if the trace pipe is closed before sending (#28075) --- pkg/security/tests/trace_pipe.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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 + } } } }()