From 8e40d688679a4ea7a56649b621e6be0929d72bf6 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 24 Oct 2023 09:45:45 +0200 Subject: 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. --- CRT.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'CRT.c') 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); } -- cgit v1.2.3