From 8ad4fa682643bf68e1c9e1a4996444e0d4616812 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Tue, 17 Mar 2020 21:55:38 +0100 Subject: [PATCH] raw_syscalls: define __NR_pidfd_send_signal if missing On all architectures we care about it's 424. Signed-off-by: Christian Brauner --- src/lxc/commands.c | 2 +- src/lxc/raw_syscalls.c | 10 +++++----- src/lxc/utils.c | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lxc/commands.c b/src/lxc/commands.c index 204af14f3..9c73bb53a 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -689,7 +689,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req, stopsignal = handler->conf->stopsignal; memset(&rsp, 0, sizeof(rsp)); - if (handler-> pidfd >= 0) + if (handler->pidfd >= 0) rsp.ret = lxc_raw_pidfd_send_signal(handler->pidfd, stopsignal, NULL, 0); else rsp.ret = kill(handler->pid, stopsignal); diff --git a/src/lxc/raw_syscalls.c b/src/lxc/raw_syscalls.c index bfa48c034..d30b93863 100644 --- a/src/lxc/raw_syscalls.c +++ b/src/lxc/raw_syscalls.c @@ -123,13 +123,13 @@ pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags, return pid; } +/* For all the architectures we care about it's the same syscall number. */ +#ifndef __NR_pidfd_send_signal +#define __NR_pidfd_send_signal 424 +#endif + int lxc_raw_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, unsigned int flags) { -#ifdef __NR_pidfd_send_signal return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); -#else - errno = ENOSYS; - return -1; -#endif } diff --git a/src/lxc/utils.c b/src/lxc/utils.c index a3b5f128f..25ae794b0 100644 --- a/src/lxc/utils.c +++ b/src/lxc/utils.c @@ -1833,5 +1833,9 @@ bool lxc_can_use_pidfd(int pidfd) if (ret < 0) return log_error_errno(false, errno, "Kernel does not support waiting on processes through pidfds"); + ret = lxc_raw_pidfd_send_signal(pidfd, 0, NULL, 0); + if (ret) + return log_error_errno(false, errno, "Kernel does not support sending singals through pidfds"); + return log_trace(true, "Kernel supports pidfds"); } -- 2.47.2