Tests/Kernel: Reset SIGCHLD's handler at the end of TestWaitFirstNoHang

With this change, when we're done with our test the SIGCHLD handler is
set back to the default one. This fixes an issue when running the test
under LSan with libsanitizers. LSan works by forking and then using
ptrace on the parent to inspect its address space, when this child exits
it was triggering our handler and caused a crash. Restoring the default
handler solves the issue. For some reason, this only happens with GCC's
implementation of LSan while this works fine with Clang's.
This commit is contained in:
Lucas Chollet authored and Sönke Holz committed 2026-10-06 15:27:13 +02:00
1 parent cc35ecf5b9
commit 0a8a147389
1 file changed
+4 -2
@@ -23,11 +23,11 @@ static void sigchld_handler(int, siginfo_t* siginfo, void*)
static void run_test(auto callback)
{
struct sigaction s;
struct sigaction s, old_sigaction;
s.sa_sigaction = sigchld_handler;
sigemptyset(&s.sa_mask);
s.sa_flags = SA_SIGINFO;
TRY_OR_FAIL(Core::System::sigaction(SIGCHLD, &s, nullptr));
TRY_OR_FAIL(Core::System::sigaction(SIGCHLD, &s, &old_sigaction));
g_wait_caller = move(callback);
@@ -46,6 +46,8 @@ static void run_test(auto callback)
sigsuspend(&prev);
EXPECT_EQ(sigprocmask(SIG_SETMASK, &prev, nullptr), 0);
TRY_OR_FAIL(Core::System::sigaction(SIGCHLD, &old_sigaction, nullptr));
}
TEST_CASE(waitid)