summaryrefslogtreecommitdiffstats
path: root/CRT.c
diff options
context:
space:
mode:
authorChristian Hesse <mail@eworm.de>2023-10-24 09:45:45 +0200
committerBenBE <BenBE@geshi.org>2024-01-15 17:05:05 +0100
commit8e40d688679a4ea7a56649b621e6be0929d72bf6 (patch)
treead67ab9faeb52597e0fbe554cca51eecdf6b061c /CRT.c
parentb6b9384678fa111d47a8d3074c31490863619d12 (diff)
CRT: print a warning when exiting on signal
Every now and then users complain about settings to being persisted. Most of the time this turns out to be caused by user: Exiting with signal causes htop not to save settings to htoprc. Make htop print a warning when exiting on signal.
Diffstat (limited to 'CRT.c')
-rw-r--r--CRT.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/CRT.c b/CRT.c
index bd5453bc..28817c23 100644
--- a/CRT.c
+++ b/CRT.c
@@ -803,8 +803,16 @@ int CRT_scrollWheelVAmount = 10;
ColorScheme CRT_colorScheme = COLORSCHEME_DEFAULT;
ATTR_NORETURN
-static void CRT_handleSIGTERM(ATTR_UNUSED int sgn) {
+static void CRT_handleSIGTERM(int sgn) {
CRT_done();
+
+ const char* signal_str = strsignal(sgn);
+ if (!signal_str)
+ signal_str = "unknown reason";
+
+ fprintf(stderr,
+ "A signal %d (%s) was received, exiting without persisting settings to htoprc.\n",
+ sgn, signal_str);
_exit(0);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy