From 5e134a40b0a4fb7de8e34eb0e2d4938a1da86491 Mon Sep 17 00:00:00 2001 From: git-bruh Date: Mon, 10 Jan 2022 17:02:26 +0530 Subject: [PATCH] save errno in resize handler, deinit signal handler in tb_shutdown() --- termbox.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/termbox.h b/termbox.h index 6891cf7..3cc79f4 100644 --- a/termbox.h +++ b/termbox.h @@ -2117,6 +2117,8 @@ static int tb_deinit() { global.ttyfd_open = 0; } } + + sigaction(SIGWINCH, &(struct sigaction){.sa_handler = SIG_DFL}, NULL); if (global.resize_pipefd[0] >= 0) close(global.resize_pipefd[0]); if (global.resize_pipefd[1] >= 0) @@ -2734,7 +2736,9 @@ static int resize_if_needed() { } static void handle_resize(int sig) { + int errno_copy = errno; write(global.resize_pipefd[1], &sig, sizeof(sig)); + errno = errno_copy; } static int send_attr(uintattr_t fg, uintattr_t bg) { -- 2.39.5