File aiccu_20070115-sigaction.dif of Package aiccu
--- unix-console/main.c
+++ unix-console/main.c 2007/06/22 16:42:18
@@ -22,14 +22,14 @@
g_aiccu->makebeats = !g_aiccu->makebeats;
/* Reset the signal */
- signal(i, &sigusr1);
+ /* signal(i, &sigusr1); */
}
void sigterm(int i);
void sigterm(int i)
{
g_aiccu->running = false;
- signal(i, SIG_IGN);
+ /* signal(i, SIG_IGN); */
}
int sigrunning(int sig);
@@ -449,18 +449,36 @@
/* mode == A_START */
#ifndef _WIN32
+ {
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sigemptyset(&sa.sa_mask);
+
+#if defined(SIGWINCH)
+ /* don't get confused by resizing windows */
+ sa.sa_handler = SIG_IGN;
+ sigaction(SIGWINCH, &sa, NULL);
+#endif
+
+ sa.sa_handler = SIG_IGN;
+ sigaction(SIGPIPE, &sa, NULL);
+
/*
* Install a signal handler so that
* one can disable beating with SIGUSR1
*/
- signal(SIGUSR1, &sigusr1);
+ sa.sa_handler = sigusr1;
+ sigaction(SIGUSR1, &sa, NULL);
/*
* Install a signal handler so that
* one can stop this program with SIGTERM
*/
- signal(SIGTERM, &sigterm);
- signal(SIGINT, &sigterm);
+ sa.sa_handler = sigterm;
+ sigaction(SIGTERM, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
+ }
#else
SetConsoleCtrlHandler((PHANDLER_ROUTINE)sigterm, true);
#endif