]> git.ipfire.org Git - thirdparty/util-linux.git/blame - include/pidfd-utils.h
Merge branch 'lslogins/man-shell' of https://github.com/t-8ch/util-linux
[thirdparty/util-linux.git] / include / pidfd-utils.h
CommitLineData
faeb1b64
KZ
1/*
2 * No copyright is claimed. This code is in the public domain; do with
3 * it what you wish.
4 */
6e6b9a1d
SK
5#ifndef UTIL_LINUX_PIDFD_UTILS
6#define UTIL_LINUX_PIDFD_UTILS
7
319563bf 8#ifdef HAVE_SYS_SYSCALL_H
6e6b9a1d 9# include <sys/syscall.h>
7f45939f
MM
10
11/*
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.
14 */
15#ifndef __NR_pidfd_send_signal
16#define __NR_pidfd_send_signal 424
17#define SYS_pidfd_send_signal __NR_pidfd_send_signal
18#endif
19#ifndef __NR_pidfd_open
20#define __NR_pidfd_open 434
21#define SYS_pidfd_open __NR_pidfd_open
22#endif
23
0a4035ff 24# if defined(SYS_pidfd_send_signal) && defined(SYS_pidfd_open)
84732a88
KR
25# ifdef HAVE_SYS_PIDFD_H
26# include <sys/pidfd.h>
27# endif
3cfde037 28# include <sys/types.h>
0a4035ff 29# ifndef HAVE_PIDFD_SEND_SIGNAL
97af76c4 30# include <sys/wait.h>
6e6b9a1d
SK
31static inline int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
32 unsigned int flags)
33{
34 return syscall(SYS_pidfd_send_signal, pidfd, sig, info, flags);
35}
3cfde037 36# endif
b6c3de88 37
0a4035ff 38# ifndef HAVE_PIDFD_OPEN
6e6b9a1d
SK
39static inline int pidfd_open(pid_t pid, unsigned int flags)
40{
41 return syscall(SYS_pidfd_open, pid, flags);
42}
3cfde037 43# endif
b6c3de88 44
3cfde037 45# define UL_HAVE_PIDFD 1
6e6b9a1d 46
3cfde037 47# endif /* SYS_pidfd_send_signal */
319563bf 48#endif /* HAVE_SYS_SYSCALL_H */
b6c3de88 49#endif /* UTIL_LINUX_PIDFD_UTILS */