]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: handle kernel header and kernel incompatability 3249/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 9 Jan 2020 11:25:30 +0000 (12:25 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 9 Jan 2020 11:30:14 +0000 (12:30 +0100)
We might e.g. be compiled in a container with old kernel headers. In this
scenario CLONE_PIDFD will work but pidfd_send_signal() might not be detected
because __NR_pidfd_send_signal is not defined because the kernel headers don't
match the kernel version.

This explains and fixes test-suite hangs on Jenkins I've recently debugged.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c

index f085aa60d04eace6cae49e080de5f0d65d043b33..9ca85911ce553e03ea814c3dad61aae4bbaf1c92 100644 (file)
@@ -1091,11 +1091,13 @@ void lxc_abort(const char *name, struct lxc_handler *handler)
 
        lxc_set_state(name, handler, ABORTING);
 
-       if (handler->pidfd >= 0)
+       if (handler->pidfd >= 0) {
                ret = lxc_raw_pidfd_send_signal(handler->pidfd, SIGKILL, NULL, 0);
-       else if (handler->pid > 0)
-               ret = kill(handler->pid, SIGKILL);
-       if (ret < 0)
+               if (ret)
+                       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);
 
        do {