From 96509847b9614dad6fdbc20fad1330c03bf8cade Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 15 Jul 2024 15:45:09 -0700 Subject: [PATCH] remote: avoid signal names map on init Signed-off-by: Tonis Tiigi --- controller/remote/io.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/controller/remote/io.go b/controller/remote/io.go index 6a8c59c3..6b8f7646 100644 --- a/controller/remote/io.go +++ b/controller/remote/io.go @@ -207,6 +207,7 @@ func attachIO(ctx context.Context, stream msgStream, initMessage *pb.InitMessage if cfg.signal != nil { eg.Go(func() error { + names := signalNames() for { var sig syscall.Signal select { @@ -216,7 +217,7 @@ func attachIO(ctx context.Context, stream msgStream, initMessage *pb.InitMessage case <-ctx.Done(): return nil } - name := sigToName[sig] + name := names[sig] if name == "" { continue } @@ -380,12 +381,12 @@ func copyToStream(fd uint32, snd msgStream, r io.Reader) error { }) } -var sigToName = map[syscall.Signal]string{} - -func init() { +func signalNames() map[syscall.Signal]string { + m := make(map[syscall.Signal]string, len(signal.SignalMap)) for name, value := range signal.SignalMap { - sigToName[value] = name + m[value] = name } + return m } type debugStream struct {