Skip to content

Commit

Permalink
/quit now exits from the event loop
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sjaeckel committed Jan 8, 2025
1 parent 6794d22 commit 0531441
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/command/cmd_funcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion src/profanity.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/profanity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 0531441

Please sign in to comment.