From 4e8c092266e28589abd5ca149ee8b3a43a9a6ee0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Mon, 13 May 2024 20:21:24 +0200 Subject: [PATCH] include/pidfd-utils: provide ENOSYS stubs if pidfd functions are missing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This allows code which can gracefully fall back to compile. This should fix the CI on Ubuntu 18.04. Signed-off-by: Thomas Weißschuh --- include/pidfd-utils.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/include/pidfd-utils.h b/include/pidfd-utils.h index 4f6f51b81..4ac9f79d9 100644 --- a/include/pidfd-utils.h +++ b/include/pidfd-utils.h @@ -5,6 +5,9 @@ #ifndef UTIL_LINUX_PIDFD_UTILS #define UTIL_LINUX_PIDFD_UTILS +#include +#include + #ifdef HAVE_SYS_SYSCALL_H # include # include @@ -13,9 +16,7 @@ # ifdef HAVE_SYS_PIDFD_H # include # endif -# include # ifndef HAVE_PIDFD_SEND_SIGNAL -# include static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info, unsigned int flags) { @@ -34,4 +35,23 @@ static inline int pidfd_open(pid_t pid, unsigned int flags) # endif /* SYS_pidfd_send_signal */ #endif /* HAVE_SYS_SYSCALL_H */ + +#ifndef UL_HAVE_PIDFD +static inline int pidfd_send_signal(int pidfd __attribute__((unused)), + int sig __attribute__((unused)), + siginfo_t *info __attribute__((unused)), + unsigned int flags __attribute__((unused))) +{ + errno = ENOSYS; + return -1; +} + +static inline int pidfd_open(pid_t pid __attribute__((unused)), + unsigned int flags __attribute__((unused))) +{ + errno = ENOSYS; + return -1; +} +#endif + #endif /* UTIL_LINUX_PIDFD_UTILS */ -- 2.47.2