From b7ae5619451ff5c796108bc87f46138c3a8ca923 Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Wed, 30 Jun 2021 21:34:12 -0600 Subject: [PATCH] LibTest: Clear core dump flag for CrashTest child processes Because these processes are expected to crash, generating a core dump from them and throwing up a CrashReporter window is less helpful than it is distracting while running many tests at a time. Use the prctl for controlling the core dump-able flag to tell the kernel we don't want core dumps from these processes. Note that because we also build LibTest for Lagom, we have to check for MacOS which doesn't support prctl(PR_SET_DUMPABLE). --- Userland/Libraries/LibTest/CrashTest.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Userland/Libraries/LibTest/CrashTest.cpp b/Userland/Libraries/LibTest/CrashTest.cpp index 5eba071c75..bcb7b83f1a 100644 --- a/Userland/Libraries/LibTest/CrashTest.cpp +++ b/Userland/Libraries/LibTest/CrashTest.cpp @@ -6,10 +6,15 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include #include #include #include +#ifndef AK_OS_MACOS +# include +#endif + namespace Test { Crash::Crash(String test_type, Function crash_function) @@ -49,6 +54,10 @@ bool Crash::run(RunType run_type) perror("fork"); VERIFY_NOT_REACHED(); } else if (pid == 0) { +#ifndef AK_OS_MACOS + if (prctl(PR_SET_DUMPABLE, 0, 0) < 0) + perror("prctl(PR_SET_DUMPABLE)"); +#endif run_crash_and_print_if_error(); exit(0); }