]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/pidfd-utils: provide ENOSYS stubs if pidfd functions are missing
authorThomas Weißschuh <thomas@t-8ch.de>
Mon, 13 May 2024 18:21:24 +0000 (20:21 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 2 Jul 2024 13:18:45 +0000 (15:18 +0200)
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 <thomas@t-8ch.de>
(cherry picked from commit 4e8c092266e28589abd5ca149ee8b3a43a9a6ee0)

include/pidfd-utils.h

index 2fe4f5a7f20cb0dbdcacae2ae1fa0dbd7f01eae0..aa4cce5a3f38e969480801f6819639da397a814a 100644 (file)
@@ -5,6 +5,9 @@
 #ifndef UTIL_LINUX_PIDFD_UTILS
 #define UTIL_LINUX_PIDFD_UTILS
 
+#include <sys/types.h>
+#include <sys/wait.h>
+
 #ifdef HAVE_SYS_SYSCALL_H
 # include <sys/syscall.h>
 
@@ -12,9 +15,7 @@
 #  ifdef HAVE_SYS_PIDFD_H
 #   include <sys/pidfd.h>
 #  endif
-#  include <sys/types.h>
 #  ifndef HAVE_PIDFD_SEND_SIGNAL
-#   include <sys/wait.h>
 static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
                                    unsigned int flags)
 {
@@ -33,4 +34,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 */