/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 <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-01-06 12:35:06 +01:00
parent 2696989ce5
commit 8151dfa3b4
3 changed files with 6 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -41,7 +41,7 @@
#include <glib.h>
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;