• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 
3 #ifndef _UAPI_LINUX_PIDFD_H
4 #define _UAPI_LINUX_PIDFD_H
5 
6 #include <linux/types.h>
7 #include <linux/fcntl.h>
8 #include <linux/ioctl.h>
9 
10 /* Flags for pidfd_open().  */
11 #define PIDFD_NONBLOCK	O_NONBLOCK
12 #define PIDFD_THREAD	O_EXCL
13 
14 /* Flags for pidfd_send_signal(). */
15 #define PIDFD_SIGNAL_THREAD		(1UL << 0)
16 #define PIDFD_SIGNAL_THREAD_GROUP	(1UL << 1)
17 #define PIDFD_SIGNAL_PROCESS_GROUP	(1UL << 2)
18 
19 #define PIDFS_IOCTL_MAGIC 0xFF
20 
21 #define PIDFD_GET_CGROUP_NAMESPACE            _IO(PIDFS_IOCTL_MAGIC, 1)
22 #define PIDFD_GET_IPC_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 2)
23 #define PIDFD_GET_MNT_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 3)
24 #define PIDFD_GET_NET_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 4)
25 #define PIDFD_GET_PID_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 5)
26 #define PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE  _IO(PIDFS_IOCTL_MAGIC, 6)
27 #define PIDFD_GET_TIME_NAMESPACE              _IO(PIDFS_IOCTL_MAGIC, 7)
28 #define PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE _IO(PIDFS_IOCTL_MAGIC, 8)
29 #define PIDFD_GET_USER_NAMESPACE              _IO(PIDFS_IOCTL_MAGIC, 9)
30 #define PIDFD_GET_UTS_NAMESPACE               _IO(PIDFS_IOCTL_MAGIC, 10)
31 
32 /*
33  * The concept of process and threads in userland and the kernel is a confusing
34  * one - within the kernel every thread is a 'task' with its own individual PID,
35  * however from userland's point of view threads are grouped by a single PID,
36  * which is that of the 'thread group leader', typically the first thread
37  * spawned.
38  *
39  * To cut the Gideon knot, for internal kernel usage, we refer to
40  * PIDFD_SELF_THREAD to refer to the current thread (or task from a kernel
41  * perspective), and PIDFD_SELF_THREAD_GROUP to refer to the current thread
42  * group leader...
43  */
44 #define PIDFD_SELF_THREAD		-10000 /* Current thread. */
45 #define PIDFD_SELF_THREAD_GROUP		-20000 /* Current thread group leader. */
46 
47 /*
48  * ...and for userland we make life simpler - PIDFD_SELF refers to the current
49  * thread, PIDFD_SELF_PROCESS refers to the process thread group leader.
50  *
51  * For nearly all practical uses, a user will want to use PIDFD_SELF.
52  */
53 #define PIDFD_SELF		PIDFD_SELF_THREAD
54 #define PIDFD_SELF_PROCESS	PIDFD_SELF_THREAD_GROUP
55 
56 #endif /* _UAPI_LINUX_PIDFD_H */
57