diff options
-rw-r--r-- | Userland/Libraries/LibMain/Main.cpp | 18 | ||||
-rw-r--r-- | Userland/Libraries/LibMain/Main.h | 3 |
2 files changed, 20 insertions, 1 deletions
diff --git a/Userland/Libraries/LibMain/Main.cpp b/Userland/Libraries/LibMain/Main.cpp index 67eea7ca50..81b4bb8ffb 100644 --- a/Userland/Libraries/LibMain/Main.cpp +++ b/Userland/Libraries/LibMain/Main.cpp @@ -11,6 +11,22 @@ #include <string.h> #include <time.h> +namespace Main { + +static int s_return_code_for_errors = 1; + +int return_code_for_errors() +{ + return s_return_code_for_errors; +} + +void set_return_code_for_errors(int code) +{ + s_return_code_for_errors = code; +} + +} + int main(int argc, char** argv) { tzset(); @@ -31,7 +47,7 @@ int main(int argc, char** argv) #ifdef __serenity__ dbgln("\033[31;1mExiting with runtime error\033[0m: {}", error); #endif - return 1; + return Main::return_code_for_errors(); } return result.value(); } diff --git a/Userland/Libraries/LibMain/Main.h b/Userland/Libraries/LibMain/Main.h index bc66c1aac3..9fee321b8d 100644 --- a/Userland/Libraries/LibMain/Main.h +++ b/Userland/Libraries/LibMain/Main.h @@ -19,6 +19,9 @@ struct Arguments { Span<StringView> strings; }; +int return_code_for_errors(); +void set_return_code_for_errors(int); + } ErrorOr<int> serenity_main(Main::Arguments); |