From 6650510836704c3ccf2af4eca60e4e9487f91601 Mon Sep 17 00:00:00 2001 From: Brian Goff Date: Fri, 4 Sep 2020 15:51:30 -0700 Subject: [PATCH] Exit signal forward if process not found Previously the signal loop can end up racing with the process exiting. Intead of logging and continuing the loop, exit early. Signed-off-by: Brian Goff --- cmd/ctr/commands/signals.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/ctr/commands/signals.go b/cmd/ctr/commands/signals.go index 51afb0f7b..d0c1daa9b 100644 --- a/cmd/ctr/commands/signals.go +++ b/cmd/ctr/commands/signals.go @@ -23,6 +23,7 @@ import ( "syscall" "github.com/containerd/containerd" + "github.com/containerd/containerd/errdefs" "github.com/sirupsen/logrus" ) @@ -38,6 +39,10 @@ func ForwardAllSignals(ctx gocontext.Context, task killer) chan os.Signal { for s := range sigc { logrus.Debug("forwarding signal ", s) if err := task.Kill(ctx, s.(syscall.Signal)); err != nil { + if errdefs.IsNotFound(err) { + logrus.WithError(err).Debugf("Not forwarding signal %s", s) + return + } logrus.WithError(err).Errorf("forward signal %s", s) } }