]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/pidfd: adapt to recent changes
authorChristian Brauner <brauner@kernel.org>
Thu, 3 Apr 2025 14:09:01 +0000 (16:09 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 7 Apr 2025 07:38:24 +0000 (09:38 +0200)
Adapt to changes in commit 9133607de37a ("exit: fix the usage of
delay_group_leader->exit_code in do_notify_parent() and pidfs_exit()").

Even if the thread-group leader exited early and succesfully it's exit
status will only be reported once the whole thread-group has exited and
it will share the exit code of the thread-group. So if the thread-group
was SIGKILLed the thread-group leader will also be reported as having
been SIGKILLed.

Link: https://lore.kernel.org/r/20250403-work-pidfd-fixes-v1-1-a123b6ed6716@kernel.org
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
tools/testing/selftests/pidfd/pidfd_info_test.c

index 1758a1b0457be36294ef38570fb2821b3cd371c0..accfd6bdc539e57173bf8fbb763eff687321168e 100644 (file)
@@ -362,9 +362,9 @@ TEST_F(pidfd_info, thread_group)
        ASSERT_EQ(ioctl(pidfd_leader, PIDFD_GET_INFO, &info), 0);
        ASSERT_FALSE(!!(info.mask & PIDFD_INFO_CREDS));
        ASSERT_TRUE(!!(info.mask & PIDFD_INFO_EXIT));
-       /* The thread-group leader exited successfully. Only the specific thread was SIGKILLed. */
-       ASSERT_TRUE(WIFEXITED(info.exit_code));
-       ASSERT_EQ(WEXITSTATUS(info.exit_code), 0);
+       /* Even though the thread-group exited successfully it will still report the group exit code. */
+       ASSERT_TRUE(WIFSIGNALED(info.exit_code));
+       ASSERT_EQ(WTERMSIG(info.exit_code), SIGKILL);
 
        /*
         * Retrieve exit information for the thread-group leader via the
@@ -375,9 +375,9 @@ TEST_F(pidfd_info, thread_group)
        ASSERT_FALSE(!!(info2.mask & PIDFD_INFO_CREDS));
        ASSERT_TRUE(!!(info2.mask & PIDFD_INFO_EXIT));
 
-       /* The thread-group leader exited successfully. Only the specific thread was SIGKILLed. */
-       ASSERT_TRUE(WIFEXITED(info2.exit_code));
-       ASSERT_EQ(WEXITSTATUS(info2.exit_code), 0);
+       /* Even though the thread-group exited successfully it will still report the group exit code. */
+       ASSERT_TRUE(WIFSIGNALED(info2.exit_code));
+       ASSERT_EQ(WTERMSIG(info2.exit_code), SIGKILL);
 
        /* Retrieve exit information for the thread. */
        info.mask = PIDFD_INFO_CGROUPID | PIDFD_INFO_EXIT;