From efd441506270b227ce781f3faa8f4b19a3ebc869 Mon Sep 17 00:00:00 2001 From: Iceber Gu Date: Mon, 8 Jul 2024 17:21:50 +0800 Subject: [PATCH] client: fix tasks with PID 0 cannot be forced to delete Signed-off-by: Iceber Gu --- client/task_opts.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/task_opts.go b/client/task_opts.go index 177e80cb5..8e94d4c59 100644 --- a/client/task_opts.go +++ b/client/task_opts.go @@ -151,6 +151,12 @@ type ProcessDeleteOpts func(context.Context, Process) error // WithProcessKill will forcefully kill and delete a process func WithProcessKill(ctx context.Context, p Process) error { + // Skip killing tasks with PID 0 + // https://github.com/containerd/containerd/issues/10441 + if p.Pid() == 0 { + return nil + } + ctx, cancel := context.WithCancel(ctx) defer cancel() // ignore errors to wait and kill as we are forcefully killing