From: Christian Brauner Date: Tue, 17 Mar 2020 20:55:38 +0000 (+0100) Subject: raw_syscalls: define __NR_pidfd_send_signal if missing X-Git-Tag: lxc-4.0.0~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3303%2Fhead;p=thirdparty%2Flxc.git raw_syscalls: define __NR_pidfd_send_signal if missing On all architectures we care about it's 424. Signed-off-by: Christian Brauner --- 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"); }