/linux/tools/testing/selftests/pidfd/ |
H A D | pidfd_file_handle_test.c | 28 int pidfd; in FIXTURE() local 47 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 48 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 119 EXPECT_EQ(close(self->pidfd), 0); in FIXTURE_TEARDOWN() 148 int pidfd = -EBADF; in TEST_F() local 160 pidfd = open_by_handle_at(self->pidfd, fh, 0); in TEST_F() 161 ASSERT_GE(pidfd, 0); in TEST_F() 163 ASSERT_EQ(fstat(pidfd, &st2), 0); in TEST_F() 166 ASSERT_EQ(close(pidfd), 0); in TEST_F() 168 pidfd = open_by_handle_at(self->pidfd, fh, O_CLOEXEC); in TEST_F() [all …]
|
H A D | pidfd_wait.c | 31 int pidfd = -1; in TEST() local 35 .pidfd = ptr_to_u64(&pidfd), in TEST() 44 pidfd = open("/proc/self", O_DIRECTORY | O_RDONLY | O_CLOEXEC); in TEST() 45 ASSERT_GE(pidfd, 0); in TEST() 47 pid = sys_waitid(P_PIDFD, pidfd, &info, WEXITED); in TEST() 49 EXPECT_EQ(close(pidfd), 0); in TEST() 50 pidfd = -1; in TEST() 52 pidfd = open("/dev/null", O_RDONLY | O_CLOEXEC); in TEST() 53 ASSERT_GE(pidfd, 0); in TEST() 55 pid = sys_waitid(P_PIDFD, pidfd, &info, WEXITED); in TEST() [all …]
|
H A D | pidfd_test.c | 22 #include "pidfd.h" 33 static pid_t pidfd_clone(int flags, int *pidfd, int (*fn)(void *)) in pidfd_clone() argument 39 return __clone2(fn, stack, stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 41 return clone(fn, stack + stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 59 int pidfd, ret; in test_pidfd_send_signal_simple_success() local 69 pidfd = open("/proc/self", O_DIRECTORY | O_CLOEXEC); in test_pidfd_send_signal_simple_success() 70 if (pidfd < 0) in test_pidfd_send_signal_simple_success() 77 ret = sys_pidfd_send_signal(pidfd, SIGUSR1, NULL, 0); in test_pidfd_send_signal_simple_success() 78 close(pidfd); in test_pidfd_send_signal_simple_success() 94 int pidfd, re in test_pidfd_send_signal_exited_fail() local 201 int pidfd = -1; test_pidfd_send_signal_recycled_pid_fail() local 353 int pidfd, ret; test_pidfd_send_signal_syscall_support() local 395 poll_pidfd(const char * test_name,int pidfd) poll_pidfd() argument 445 int pid, pidfd = 0; test_pidfd_poll_exec() local 511 int pid, pidfd = 0; test_pidfd_poll_leader_exit() local [all...] |
H A D | pidfd_bind_mount.c | 95 int pidfd; in FIXTURE() local 111 self->pidfd = sys_pidfd_open(getpid(), 0); in FIXTURE_SETUP() 112 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 113 ASSERT_GE(fstat(self->pidfd, &self->st1), 0); in FIXTURE_SETUP() 114 ASSERT_EQ(ioctl(self->pidfd, FS_IOC_GETVERSION, &self->gen1), 0); in FIXTURE_SETUP() 133 fd_tree = sys_open_tree(self->pidfd, "", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC | AT_EMPTY_PATH); in TEST_F() 145 int pidfd; in TEST_F() local 148 sprintf(proc_path, "/proc/self/fd/%d", self->pidfd); in TEST_F() 149 pidfd = open(proc_path, O_RDONLY | O_NOCTTY | O_CLOEXEC); in TEST_F() 150 ASSERT_GE(pidfd, 0); in TEST_F() [all …]
|
H A D | pidfd.h | 106 static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, in sys_pidfd_send_signal() argument 109 return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); in sys_pidfd_send_signal() 112 static inline int sys_pidfd_getfd(int pidfd, int fd, int flags) in sys_pidfd_getfd() argument 114 return syscall(__NR_pidfd_getfd, pidfd, fd, flags); in sys_pidfd_getfd() 122 static inline pid_t create_child(int *pidfd, unsigned flags) in create_child() argument 127 .pidfd = ptr_to_u64(pidfd), in create_child()
|
H A D | pidfd_poll_test.c | 48 int pidfd; in main() local 68 pidfd = sys_pidfd_open(child_pid, 0); in main() 69 if (pidfd < 0) in main() 80 if (sys_pidfd_send_signal(pidfd, SIGKILL, NULL, 0)) in main() 85 fds.fd = pidfd; in main() 106 close(pidfd); in main()
|
H A D | pidfd_getfd_test.c | 127 int pidfd; in FIXTURE() local 157 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 158 ASSERT_GE(self->pidfd, 0); in FIXTURE_SETUP() 172 EXPECT_EQ(0, close(self->pidfd)); in FIXTURE_TEARDOWN() 198 fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0); in TEST_F() 210 fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0); in TEST_F() 229 fd = sys_pidfd_getfd(self->pidfd, UNKNOWN_FD, 0); in TEST_F() 250 fds.fd = self->pidfd; in TEST_F() 263 EXPECT_EQ(sys_pidfd_getfd(self->pidfd, self->remote_fd, 0), -1); in TEST_F()
|
H A D | pidfd_fdinfo_test.c | 164 static int verify_fdinfo(int pidfd, struct error *err, const char *prefix, in verify_fdinfo() argument 181 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in verify_fdinfo() 185 pidfd); in verify_fdinfo() 211 prefix, pidfd); in verify_fdinfo() 219 int pidfd; in child_fdinfo_nspid_test() local 243 pidfd = *(int *)args; in child_fdinfo_nspid_test() 244 r = verify_fdinfo(pidfd, &err, "NSpid:", 6, "\t0\n"); in child_fdinfo_nspid_test()
|
H A D | pidfd_setns_test.c | 102 int pidfd; in FIXTURE() local 157 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 158 EXPECT_GT(self->pidfd, 0) { in FIXTURE_SETUP() 172 self->child_pidfd_derived_nsfds[i] = ioctl(self->pidfd, info->pidfd_ioctl, 0); in FIXTURE_SETUP() 195 self->pidfd = sys_pidfd_open(self->pid, 0); in FIXTURE_SETUP() 196 EXPECT_GE(self->pidfd, 0) { in FIXTURE_SETUP() 444 ASSERT_NE(setns(self->pidfd, 0), 0); in TEST_F() 447 ASSERT_NE(setns(self->pidfd, -1), 0); in TEST_F() 450 ASSERT_NE(setns(self->pidfd, CLONE_VM), 0); in TEST_F() 453 ASSERT_NE(setns(self->pidfd, CLONE_NEWUSER | CLONE_VM), 0); in TEST_F()
|
/linux/samples/pidfd/ |
H A D | pidfd-metadata.c | 34 static pid_t pidfd_clone(int flags, int *pidfd) in pidfd_clone() argument 40 return __clone2(do_child, stack, stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 42 return clone(do_child, stack + stack_size, flags | SIGCHLD, NULL, pidfd); in pidfd_clone() 46 static inline int sys_pidfd_send_signal(int pidfd, int sig, siginfo_t *info, in sys_pidfd_send_signal() argument 49 return syscall(__NR_pidfd_send_signal, pidfd, sig, info, flags); in sys_pidfd_send_signal() 52 static int pidfd_metadata_fd(pid_t pid, int pidfd) in pidfd_metadata_fd() argument 68 ret = sys_pidfd_send_signal(pidfd, 0, NULL, 0); in pidfd_metadata_fd() 86 int pidfd = -1, ret = EXIT_FAILURE; in main() local 92 pid = pidfd_clone(CLONE_PIDFD, &pidfd); in main() 95 if (pidfd == -1) { in main() [all …]
|
H A D | .gitignore | 2 /pidfd-metadata
|
H A D | Makefile | 2 usertprogs-always-y += pidfd-metadata
|
/linux/tools/testing/selftests/mm/ |
H A D | mrelease_test.c | 51 static void run_negative_tests(int pidfd) in run_negative_tests() argument 54 if (!syscall(__NR_process_mrelease, pidfd, (unsigned int)-1) || in run_negative_tests() 62 if (!syscall(__NR_process_mrelease, pidfd, 0) || errno != EINVAL) in run_negative_tests() 79 int pipefd[2], pidfd; in main() local 137 pidfd = syscall(__NR_pidfd_open, pid, 0); in main() 138 if (pidfd < 0) { in main() 145 run_negative_tests(pidfd); in main() 150 success = (syscall(__NR_process_mrelease, pidfd, 0) == 0); in main() 171 close(pidfd); in main()
|
/linux/samples/vfs/ |
H A D | mountinfo.c | 214 int pidfd, mntns, ret, opt; in main() local 236 pidfd = syscall(__NR_pidfd_open, pid, 0); in main() 237 if (pidfd < 0) { in main() 243 mntns = ioctl(pidfd, PIDFD_GET_MNT_NAMESPACE, NULL); in main() 248 close(pidfd); in main()
|
H A D | test-list-all-mounts.c | 75 int ret, pidfd, fd_mntns; in main() local 78 pidfd = sys_pidfd_open(getpid(), 0); in main() 79 if (pidfd < 0) in main() 82 fd_mntns = ioctl(pidfd, PIDFD_GET_MNT_NAMESPACE, 0); in main()
|
/linux/tools/testing/selftests/net/af_unix/ |
H A D | scm_pidfd.c | 94 static pid_t get_pid_from_fdinfo_file(int pidfd, const char *key, size_t keylen) in get_pid_from_fdinfo_file() argument 103 snprintf(path, sizeof(path), "/proc/self/fdinfo/%d", pidfd); in get_pid_from_fdinfo_file() 138 int *pidfd = NULL; in cmsg_check() local 165 if (cmsg->cmsg_len < sizeof(*pidfd)) { in cmsg_check() 170 pidfd = (void *)CMSG_DATA(cmsg); in cmsg_check() 190 if (!pidfd) { in cmsg_check() 202 get_pid_from_fdinfo_file(*pidfd, "Pid:", sizeof("Pid:") - 1); in cmsg_check()
|
/linux/tools/testing/selftests/pid_namespace/ |
H A D | Makefile | 6 LOCAL_HDRS += $(selfdir)/pidfd/pidfd.h
|
/linux/tools/testing/selftests/cgroup/ |
H A D | Makefile | 21 LOCAL_HDRS += $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidfd.h
|
/linux/arch/sparc/kernel/ |
H A D | process.c | 80 args.pidfd = compat_ptr(regs->u_regs[UREG_I2]); in sparc_clone() 86 args.pidfd = (int __user *)regs->u_regs[UREG_I2]; in sparc_clone()
|
/linux/kernel/ |
H A D | fork.c | 2035 int pidfd; in __pidfd_prepare() local 2038 pidfd = get_unused_fd_flags(O_CLOEXEC); in __pidfd_prepare() 2039 if (pidfd < 0) in __pidfd_prepare() 2040 return pidfd; in __pidfd_prepare() 2044 put_unused_fd(pidfd); in __pidfd_prepare() 2053 return pidfd; in __pidfd_prepare() 2153 int pidfd = -1, retval; in copy_process() local 2439 pidfd = retval; in copy_process() 2441 retval = put_user(pidfd, args->pidfd); in copy_process() 2625 fd_install(pidfd, pidfile); in copy_process() [all …]
|
/linux/tools/testing/selftests/clone3/ |
H A D | clone3_selftests.h | 24 __aligned_u64 pidfd; member
|
/linux/tools/include/uapi/linux/ |
H A D | sched.h |
|
/linux/include/uapi/linux/ |
H A D | sched.h | 94 __aligned_u64 pidfd; member
|
/linux/tools/perf/trace/beauty/include/uapi/linux/ |
H A D | sched.h | 94 __aligned_u64 pidfd; member
|
/linux/samples/ |
H A D | Makefile | 19 subdir-$(CONFIG_SAMPLE_PIDFD) += pidfd
|