From 2f8fac3528a46f4d5edb8d166a006287e4f47243 Mon Sep 17 00:00:00 2001 From: Michel Hermier Date: Wed, 15 Dec 2021 16:03:26 +0100 Subject: [PATCH] LibTest: Change `Crash` forked process communication Now it returns `Failure` value via `exit`, and the caller is responsible of reporting errors to the user. --- Userland/Libraries/LibTest/CrashTest.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibTest/CrashTest.cpp b/Userland/Libraries/LibTest/CrashTest.cpp index aff77990bfb..2610c10c987 100644 --- a/Userland/Libraries/LibTest/CrashTest.cpp +++ b/Userland/Libraries/LibTest/CrashTest.cpp @@ -40,17 +40,19 @@ bool Crash::run(RunType run_type) if (prctl(PR_SET_DUMPABLE, 0, 0) < 0) perror("prctl(PR_SET_DUMPABLE)"); #endif - return do_report(m_crash_function()); - exit(0); + exit((int)m_crash_function()); } int status; waitpid(pid, &status, 0); + if (WIFEXITED(status)) { + return do_report(Failure(WEXITSTATUS(status))); + } if (WIFSIGNALED(status)) { outln("\x1B[32mPASS\x1B[0m: Terminated with signal {}", WTERMSIG(status)); return true; } - return false; + VERIFY_NOT_REACHED(); } }