From f7223c6f0038fb0189dadaee26060bb3d66d41db Mon Sep 17 00:00:00 2001 From: lifupan Date: Mon, 8 Apr 2019 02:33:06 -0400 Subject: [PATCH] shimv2: fix the issue of stop container failed There is no need to send another SIGKILL signal following SIGTERM signal, otherwise, sending the SIGKILL signal would get failed since the container process would has been terminated by the previous SIGTERM signal. Fixes:#1493 Signed-off-by: lifupan --- containerd-shim-v2/service.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/containerd-shim-v2/service.go b/containerd-shim-v2/service.go index 98a16cdc1b..8e7ede431b 100644 --- a/containerd-shim-v2/service.go +++ b/containerd-shim-v2/service.go @@ -634,19 +634,7 @@ func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (*ptypes.Emp processID = execs.id } - err = s.sandbox.SignalProcess(c.id, processID, signum, r.All) - if err != nil { - return nil, err - } - - // Since the k8s will use the SIGTERM signal to stop a container by default, but - // some container processes would ignore this signal such as shell, thus it's better - // to resend another SIGKILL signal to make sure the container process terminated successfully. - if signum == syscall.SIGTERM { - err = s.sandbox.SignalProcess(c.id, processID, syscall.SIGKILL, r.All) - } - - return empty, err + return empty, s.sandbox.SignalProcess(c.id, processID, signum, r.All) } // Pids returns all pids inside the container