Переглянути джерело

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).
Andrew Kaster 4 роки тому
батько
коміт
b7ae561945
1 змінених файлів з 9 додано та 0 видалено
  1. 9 0
      Userland/Libraries/LibTest/CrashTest.cpp

+ 9 - 0
Userland/Libraries/LibTest/CrashTest.cpp

@@ -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);
         }