Skip to content

Commit a79975f

Browse files
committed
selftests/pidfd: add third PIDFD_INFO_EXIT selftest
Add a selftest for PIDFD_INFO_EXIT behavior. Link: https://lore.kernel.org/r/20250305-work-pidfs-kill_on_last_close-v3-12-c8c3d8361705@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 86c1dfd commit a79975f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tools/testing/selftests/pidfd/pidfd_info_test.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,20 @@ TEST_F(pidfd_info, sigkill_reaped)
161161
ASSERT_EQ(WTERMSIG(info.exit_code), SIGKILL);
162162
}
163163

164+
TEST_F(pidfd_info, success_exit)
165+
{
166+
struct pidfd_info info = {
167+
.mask = PIDFD_INFO_CGROUPID,
168+
};
169+
170+
/* Process has exited but not been reaped so this must work. */
171+
ASSERT_EQ(ioctl(self->child_pidfd3, PIDFD_GET_INFO, &info), 0);
172+
173+
info.mask = PIDFD_INFO_CGROUPID | PIDFD_INFO_EXIT;
174+
ASSERT_EQ(ioctl(self->child_pidfd3, PIDFD_GET_INFO, &info), 0);
175+
ASSERT_TRUE(!!(info.mask & PIDFD_INFO_CREDS));
176+
/* Process has exited but not been reaped, so no PIDFD_INFO_EXIT information yet. */
177+
ASSERT_FALSE(!!(info.mask & PIDFD_INFO_EXIT));
178+
}
179+
164180
TEST_HARNESS_MAIN

0 commit comments

Comments
 (0)