From a5dfd5eeb62ba1777187461a2627c40de29cc7a2 Mon Sep 17 00:00:00 2001 From: HawDevelopment Date: Tue, 27 Dec 2022 13:22:01 +0100 Subject: [PATCH] Utilities: Fix top utility not calling exit() on SIGINT Before, when running top, pressing Control+C (triggering SIGINT), would not call the atexit handler. Therefor not restoring stdin. --- Userland/Utilities/top.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/top.cpp b/Userland/Utilities/top.cpp index 490c673fac..ec575d317a 100644 --- a/Userland/Utilities/top.cpp +++ b/Userland/Utilities/top.cpp @@ -203,11 +203,14 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/etc/passwd", "r")); unveil(nullptr, nullptr); - signal(SIGWINCH, [](int) { + TRY(Core::System::signal(SIGWINCH, [](int) { g_window_size_changed = true; - }); - + })); + TRY(Core::System::signal(SIGINT, [](int) { + exit(0); + })); TRY(Core::System::pledge("stdio rpath tty")); + TopOption top_option; parse_args(arguments, top_option);