From 8151dfa3b409c4d97a0fb71685baadb33493fab3 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 6 Jan 2025 12:35:06 +0100 Subject: [PATCH] `/quit` now exits from the event loop Before this change issuing `/quit` directly called `exit(0)` and did not invoke all the graceful shutdown routines. Now we first try to exit from the event loop, which includes cleaning up everything. In case the event loop is stuck for some reason, you could try to issue a second `/quit`, which will then directly call `exit(0)`. Signed-off-by: Steffen Jaeckel --- src/command/cmd_funcs.c | 3 ++- src/profanity.c | 4 +++- src/profanity.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index c5d9671e..63e16415 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1328,7 +1328,8 @@ gboolean cmd_quit(ProfWin* window, const char* const command, gchar** args) { log_info("Profanity is shutting down…"); - exit(0); + if (prof_set_quit()) + exit(0); return FALSE; } diff --git a/src/profanity.c b/src/profanity.c index 94c27191..c9e69292 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -134,10 +134,12 @@ prof_run(char* log_level, char* account_name, char* config_file, char* log_file, } } -void +gboolean prof_set_quit(void) { + gboolean ret = force_quit; force_quit = TRUE; + return ret; } static void diff --git a/src/profanity.h b/src/profanity.h index ada02984..8a7d525a 100644 --- a/src/profanity.h +++ b/src/profanity.h @@ -41,7 +41,7 @@ #include void prof_run(char* log_level, char* account_name, char* config_file, char* log_file, char* theme_name); -void prof_set_quit(void); +gboolean prof_set_quit(void); extern pthread_mutex_t lock;