summaryrefslogtreecommitdiff
path: root/Userland/Utilities/top.cpp
diff options
context:
space:
mode:
authorHawDevelopment <hawdevelopment@gmail.com>2022-12-27 13:22:01 +0100
committerAndreas Kling <kling@serenityos.org>2022-12-31 00:04:19 +0100
commita5dfd5eeb62ba1777187461a2627c40de29cc7a2 (patch)
tree56882d86eb246275be7d0abbdc9f5c57102c35c2 /Userland/Utilities/top.cpp
parent058a39c6fc1f2f3394f8c49571ee8417eabb6ed9 (diff)
downloadserenity-a5dfd5eeb62ba1777187461a2627c40de29cc7a2.zip
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.
Diffstat (limited to 'Userland/Utilities/top.cpp')
-rw-r--r--Userland/Utilities/top.cpp9
1 files 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<int> 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);