display: support for SIGWINCH

This commit is contained in:
Robert Swiecki
2019-08-26 18:26:36 +02:00
parent 0924f2f952
commit dbb61a5a2e
3 changed files with 21 additions and 2 deletions
+6 -2
View File
@@ -299,8 +299,12 @@ void display_fini(void) {
display_put(ESC_SCROLL_RESET ESC_NAV_DOWN(500));
}
void display_init(void) {
atexit(display_fini);
void display_clear(void) {
display_put(ESC_CLEAR_ALL);
display_put(ESC_NAV_DOWN(500));
}
void display_init(void) {
atexit(display_fini);
display_clear();
}
+1
View File
@@ -28,6 +28,7 @@
extern void display_display(honggfuzz_t* hfuzz);
extern void display_init(void);
extern void display_clear(void);
extern void display_createTargetStr(honggfuzz_t* hfuzz);
#endif
+14
View File
@@ -47,6 +47,7 @@
#include "subproc.h"
static int sigReceived = 0;
static bool clearWin = false;
/*
* CygWin/MinGW incorrectly copies stack during fork(), so we need to keep some
@@ -72,6 +73,11 @@ static void sigHandler(int sig) {
}
return;
}
if (sig == SIGWINCH) {
ATOMIC_SET(clearWin, true);
return;
}
/* Do nothing with pings from the main thread */
if (sig == SIGUSR1) {
return;
@@ -141,6 +147,7 @@ static void setupSignalsPreThreads(void) {
sigaddset(&ss, SIGCHLD);
/* This is checked for via sigwaitinfo/sigtimedwait */
sigaddset(&ss, SIGUSR1);
sigaddset(&ss, SIGWINCH);
if (sigprocmask(SIG_SETMASK, &ss, NULL) != 0) {
PLOG_F("sigprocmask(SIG_SETMASK)");
}
@@ -168,6 +175,9 @@ static void setupSignalsPreThreads(void) {
if (sigaction(SIGCHLD, &sa, NULL) == -1) {
PLOG_F("sigaction(SIGCHLD) failed");
}
if (sigaction(SIGWINCH, &sa, NULL) == -1) {
PLOG_F("sigaction(SIGWINCH) failed");
}
}
static void setupSignalsMainThread(void) {
@@ -178,6 +188,7 @@ static void setupSignalsMainThread(void) {
sigaddset(&ss, SIGINT);
sigaddset(&ss, SIGQUIT);
sigaddset(&ss, SIGALRM);
sigaddset(&ss, SIGWINCH);
if (pthread_sigmask(SIG_UNBLOCK, &ss, NULL) != 0) {
PLOG_F("pthread_sigmask(SIG_UNBLOCK)");
}
@@ -308,6 +319,9 @@ int main(int argc, char** argv) {
for (;;) {
if (hfuzz.display.useScreen) {
if (ATOMIC_XCHG(clearWin, false)) {
display_clear();
}
display_display(&hfuzz);
}
if (ATOMIC_GET(sigReceived) > 0) {