Skip to content

Commit 2adf6ca

Browse files
committed
selftests/pidfd: add fifth 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-14-c8c3d8361705@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 2e94e4c commit 2adf6ca

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tools/testing/selftests/pidfd/pidfd_info_test.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,27 @@ TEST_F(pidfd_info, success_reaped)
195195
ASSERT_EQ(WEXITSTATUS(info.exit_code), 0);
196196
}
197197

198+
TEST_F(pidfd_info, success_reaped_poll)
199+
{
200+
struct pidfd_info info = {
201+
.mask = PIDFD_INFO_CGROUPID | PIDFD_INFO_EXIT,
202+
};
203+
struct pollfd fds = {};
204+
int nevents;
205+
206+
fds.events = POLLIN;
207+
fds.fd = self->child_pidfd2;
208+
209+
nevents = poll(&fds, 1, -1);
210+
ASSERT_EQ(nevents, 1);
211+
ASSERT_TRUE(!!(fds.revents & POLLIN));
212+
ASSERT_TRUE(!!(fds.revents & POLLHUP));
213+
214+
ASSERT_EQ(ioctl(self->child_pidfd2, PIDFD_GET_INFO, &info), 0);
215+
ASSERT_FALSE(!!(info.mask & PIDFD_INFO_CREDS));
216+
ASSERT_TRUE(!!(info.mask & PIDFD_INFO_EXIT));
217+
ASSERT_TRUE(WIFSIGNALED(info.exit_code));
218+
ASSERT_EQ(WTERMSIG(info.exit_code), SIGKILL);
219+
}
220+
198221
TEST_HARNESS_MAIN

0 commit comments

Comments
 (0)