[lxc-devel] [lxc/master] start: fix container killing logic

brauner on Github lxc-bot at linuxcontainers.org
Thu Jan 16 17:04:07 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 474 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200116/4eb45cd9/attachment.bin>
-------------- next part --------------
From 11c7d349610736f775a9ce92c64327b4fda6a9d7 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 16 Jan 2020 18:02:35 +0100
Subject: [PATCH] start: fix container killing logic

We need to account for the case where pidfd's are not supported by the kernel
in question.

Closes: #3254
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/start.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index 9ca85911ce..d70ffdf0e6 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -1094,11 +1094,13 @@ void lxc_abort(const char *name, struct lxc_handler *handler)
 	if (handler->pidfd >= 0) {
 		ret = lxc_raw_pidfd_send_signal(handler->pidfd, SIGKILL, NULL, 0);
 		if (ret)
-			SYSWARN("Failed to send SIGKILL via pidfd %d for process %d", handler->pidfd, handler->pid);
+			SYSWARN("Failed to send SIGKILL via pidfd %d for process %d",
+				handler->pidfd, handler->pid);
 	}
 
-	if (ret && (errno != ESRCH) && kill(handler->pid, SIGKILL))
-		SYSERROR("Failed to send SIGKILL to %d", handler->pid);
+	if (!ret || errno != ESRCH)
+		if (kill(handler->pid, SIGKILL))
+			SYSWARN("Failed to send SIGKILL to %d", handler->pid);
 
 	do {
 		ret = waitpid(-1, &status, 0);


More information about the lxc-devel mailing list