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 <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2020-09-04 15:51:30 -07:00
parent d4e78200d6
commit 6650510836

View File

@ -23,6 +23,7 @@ import (
"syscall" "syscall"
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/containerd/containerd/errdefs"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -38,6 +39,10 @@ func ForwardAllSignals(ctx gocontext.Context, task killer) chan os.Signal {
for s := range sigc { for s := range sigc {
logrus.Debug("forwarding signal ", s) logrus.Debug("forwarding signal ", s)
if err := task.Kill(ctx, s.(syscall.Signal)); err != nil { 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) logrus.WithError(err).Errorf("forward signal %s", s)
} }
} }