From bba193d6a0b6d6ba6c3afe7d9202432199748dc5 Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Sun, 3 Sep 2023 22:30:39 +0300 Subject: [PATCH] Tests, LibTest: Implement disabling core dumps on GNU Hurd --- Tests/LibJS/test262-runner.cpp | 7 +++++-- Userland/Libraries/LibTest/CrashTest.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Tests/LibJS/test262-runner.cpp b/Tests/LibJS/test262-runner.cpp index beb69b8b09..324ba895bc 100644 --- a/Tests/LibJS/test262-runner.cpp +++ b/Tests/LibJS/test262-runner.cpp @@ -25,7 +25,7 @@ #include #include -#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) +#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) && !defined(AK_OS_GNU_HURD) // Only used to disable core dumps # include #endif @@ -573,7 +573,10 @@ int main(int argc, char** argv) args_parser.add_option(disable_core_dumping, "Disable core dumping", "disable-core-dump", 0); args_parser.parse(arguments); -#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) +#ifdef AK_OS_GNU_HURD + if (disable_core_dumping) + setenv("CRASHSERVER", "/servers/crash-kill", true); +#elif !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) if (disable_core_dumping && prctl(PR_SET_DUMPABLE, 0, 0, 0) < 0) { perror("prctl(PR_SET_DUMPABLE)"); return exit_wrong_arguments; diff --git a/Userland/Libraries/LibTest/CrashTest.cpp b/Userland/Libraries/LibTest/CrashTest.cpp index 8a674c12b4..e642e17e51 100644 --- a/Userland/Libraries/LibTest/CrashTest.cpp +++ b/Userland/Libraries/LibTest/CrashTest.cpp @@ -12,7 +12,7 @@ #include #include -#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) +#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) && !defined(AK_OS_GNU_HURD) # include #endif @@ -38,7 +38,10 @@ bool Crash::run(RunType run_type) perror("fork"); VERIFY_NOT_REACHED(); } else if (pid == 0) { -#if !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) +#if defined(AK_OS_GNU_HURD) + // When we crash, just kill the program, don't dump core. + setenv("CRASHSERVER", "/servers/crash-kill", true); +#elif !defined(AK_OS_MACOS) && !defined(AK_OS_EMSCRIPTEN) if (prctl(PR_SET_DUMPABLE, 0, 0, 0) < 0) perror("prctl(PR_SET_DUMPABLE)"); #endif