From 698a77d06fbb32b1f04e7aaaf4b945346af325cd Mon Sep 17 00:00:00 2001 From: Ryan Kingsbury Date: Wed, 15 Nov 2017 21:17:27 -0800 Subject: [PATCH] Removes signal handler for signal 28 (terminal resize signal) The cleanup handler in this application was reponding to any and all process signals. The intent was for cleanup to run regardless of how the application was terminated (SIGTERM, SIGKILL, etc.). This behavior is inappropriate because certain signals, like 28, are simply used to notify the process of system events. Signal 28 (SIGWINCH) is used to signal a terminal resize event. It is likely the console blanking feature on the Pi is also sending this signal, which would cause a undesired shutdown of the program. --- wspr.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wspr.cpp b/wspr.cpp index a32f931..3793480 100644 --- a/wspr.cpp +++ b/wspr.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -1120,6 +1121,11 @@ void setup_peri_base_virt( int main(const int argc, char * const argv[]) { //catch all signals (like ctrl+c, ctrl+z, ...) to ensure DMA is disabled for (int i = 0; i < 64; i++) { + // Do not set up a handler for signal 28 (SIGWINCH). This signal is used + // to signify a terminal window resize event and is NOT a reason for the + // process to terminate. + if (i == SIGWINCH) + continue; struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = cleanupAndExit;