From e11f48751435ef6c5027e02f17daf03336c5e91a Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 18 Feb 2024 15:47:57 +0000 Subject: [PATCH] refactor: Terminate ncurses before writing error message to stderr. --- src/toxic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/toxic.c b/src/toxic.c index 9d9042eb7..263dcdd66 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -155,11 +155,12 @@ void exit_toxic_success(Toxic *toxic) void exit_toxic_err(const char *errmsg, int errcode) { + endwin(); + if (freopen("/dev/tty", "w", stderr)) { fprintf(stderr, "Toxic session aborted with error code %d (%s)\n", errcode, errmsg); } - endwin(); exit(EXIT_FAILURE); }