]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/pidfd-utils.h
2 * No copyright is claimed. This code is in the public domain; do with
5 #ifndef UTIL_LINUX_PIDFD_UTILS
6 #define UTIL_LINUX_PIDFD_UTILS
8 #ifdef HAVE_SYS_SYSCALL_H
9 # include <sys/syscall.h>
12 * If the kernel headers are too old to provide the syscall numbers, let's
13 * define them ourselves. This can be helpful while cross-compiling.
15 #ifndef __NR_pidfd_send_signal
16 #define __NR_pidfd_send_signal 424
17 #define SYS_pidfd_send_signal __NR_pidfd_send_signal
19 #ifndef __NR_pidfd_open
20 #define __NR_pidfd_open 434
21 #define SYS_pidfd_open __NR_pidfd_open
24 # if defined(SYS_pidfd_send_signal) && defined(SYS_pidfd_open)
25 # ifdef HAVE_SYS_PIDFD_H
26 # include <sys/pidfd.h>
28 # include <sys/types.h>
29 # ifndef HAVE_PIDFD_SEND_SIGNAL
30 # include <sys/wait.h>
31 static inline int pidfd_send_signal(int pidfd
, int sig
, siginfo_t
*info
,
34 return syscall(SYS_pidfd_send_signal
, pidfd
, sig
, info
, flags
);
38 # ifndef HAVE_PIDFD_OPEN
39 static inline int pidfd_open(pid_t pid
, unsigned int flags
)
41 return syscall(SYS_pidfd_open
, pid
, flags
);
45 # define UL_HAVE_PIDFD 1
47 # endif /* SYS_pidfd_send_signal */
48 #endif /* HAVE_SYS_SYSCALL_H */
49 #endif /* UTIL_LINUX_PIDFD_UTILS */