1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:47:46 +00:00

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).
This commit is contained in:
Andrew Kaster 2021-06-30 21:34:12 -06:00 committed by Andreas Kling
parent e4013f6cc6
commit b7ae561945

View file

@ -6,10 +6,15 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Platform.h>
#include <LibTest/CrashTest.h>
#include <sys/wait.h>
#include <unistd.h>
#ifndef AK_OS_MACOS
# include <sys/prctl.h>
#endif
namespace Test {
Crash::Crash(String test_type, Function<Crash::Failure()> 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);
}