From b24d49fc3cf12ab9b5530c50357b8005e81cda1c Mon Sep 17 00:00:00 2001 From: Jakub Wilk Date: Mon, 4 May 2020 11:32:27 +0200 Subject: [PATCH] Get rid of unsafe SIGWINCH handler The SIGWINCH signal handler was not async-signal-safe. This could cause memory corruption if the signal was delivered at an inopportune moment. Rely on ncurses' builtin SIGWINCH signal handler instead. --- ttyclock.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ttyclock.c b/ttyclock.c index ac486d6..e2848d1 100644 --- a/ttyclock.c +++ b/ttyclock.c @@ -76,7 +76,6 @@ init(void) /* Init signal handler */ sig.sa_handler = signal_handler; sig.sa_flags = 0; - sigaction(SIGWINCH, &sig, NULL); sigaction(SIGTERM, &sig, NULL); sigaction(SIGINT, &sig, NULL); sigaction(SIGSEGV, &sig, NULL); @@ -143,11 +142,6 @@ signal_handler(int signal) { switch(signal) { - case SIGWINCH: - endwin(); - init(); - break; - /* Interruption signal */ case SIGINT: case SIGTERM: ttyclock.running = False; @@ -445,6 +439,11 @@ key_event(void) switch(c = wgetch(stdscr)) { + case KEY_RESIZE: + endwin(); + init(); + break; + case KEY_UP: case 'k': case 'K':