]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
missing: define new pidfd syscalls
authorLennart Poettering <lennart@poettering.net>
Fri, 25 Oct 2019 14:06:06 +0000 (16:06 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 4 Dec 2019 09:33:41 +0000 (10:33 +0100)
meson.build
src/basic/missing_syscall.h

index 21d6968abdf47e87af26e7b6a83103748f221480..edde42ea74a6223b998e6145d1107843138454fb 100644 (file)
@@ -517,6 +517,14 @@ foreach ident : [
                                  #include <unistd.h>'''],
         ['get_mempolicy',     '''#include <stdlib.h>
                                  #include <unistd.h>'''],
+        ['pidfd_send_signal', '''#include <stdlib.h>
+                                 #include <unistd.h>
+                                 #include <signal.h>
+                                 #include <sys/wait.h>'''],
+        ['pidfd_open',        '''#include <stdlib.h>
+                                 #include <unistd.h>
+                                 #include <signal.h>
+                                 #include <sys/wait.h>'''],
 ]
 
         have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
index 1255d8b1972cca6cfd3f1d579974114ac4cdfde8..bea7be699d45dfb769937e5c44d043e0851c2f3b 100644 (file)
@@ -5,8 +5,10 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <signal.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <unistd.h>
 
 #ifdef ARCH_MIPS
@@ -524,3 +526,39 @@ static inline long missing_get_mempolicy(int *mode, unsigned long *nodemask,
 
 #define get_mempolicy missing_get_mempolicy
 #endif
+
+#if !HAVE_PIDFD_OPEN
+/* may be (invalid) negative number due to libseccomp, see PR 13319 */
+#  if ! (defined __NR_pidfd_open && __NR_pidfd_open > 0)
+#    if defined __NR_pidfd_open
+#      undef __NR_pidfd_open
+#    endif
+#    define __NR_pidfd_open 434
+#endif
+static inline int pidfd_open(pid_t pid, unsigned flags) {
+#ifdef __NR_pidfd_open
+        return syscall(__NR_pidfd_open, pid, flags);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
+#endif
+
+#if !HAVE_PIDFD_SEND_SIGNAL
+/* may be (invalid) negative number due to libseccomp, see PR 13319 */
+#  if ! (defined __NR_pidfd_send_signal && __NR_pidfd_send_signal > 0)
+#    if defined __NR_pidfd_send_signal
+#      undef __NR_pidfd_send_signal
+#    endif
+#    define __NR_pidfd_send_signal 424
+#endif
+static inline int pidfd_send_signal(int fd, int sig, siginfo_t *info, unsigned flags) {
+#ifdef __NR_pidfd_open
+        return syscall(__NR_pidfd_send_signal, fd, sig, info, flags);
+#else
+        errno = ENOSYS;
+        return -1;
+#endif
+}
+#endif