diff --git a/internal/consumer/exec.go b/internal/consumer/exec.go index 128a11b2..491c9612 100644 --- a/internal/consumer/exec.go +++ b/internal/consumer/exec.go @@ -2,10 +2,12 @@ package consumer import ( "context" + "log" + "sync" + "github.com/mozillazg/ptcpdump/bpf" "github.com/mozillazg/ptcpdump/internal/event" "github.com/mozillazg/ptcpdump/internal/metadata" - "log" ) type ExecEventConsumer struct { @@ -19,6 +21,18 @@ func NewExecEventConsumer(pcache *metadata.ProcessCache) *ExecEventConsumer { } func (c *ExecEventConsumer) Start(ctx context.Context, ch <-chan bpf.BpfExecEventT) { + wg := sync.WaitGroup{} + for i := 0; i < 5; i++ { + wg.Add(1) + go func() { + defer wg.Done() + c.worker(ctx, ch) + }() + } + wg.Wait() +} + +func (c *ExecEventConsumer) worker(ctx context.Context, ch <-chan bpf.BpfExecEventT) { for { select { case <-ctx.Done():