handling of SIGWINCH added

This commit is contained in:
Frederic Culot 2007-08-15 15:30:17 +00:00
parent 3d2aab3cb7
commit 1096c2d29f

View File

@ -1,4 +1,4 @@
/* $Id: sigs.c,v 1.2 2007/07/28 13:11:42 culot Exp $ */ /* $Id: sigs.c,v 1.3 2007/08/15 15:30:17 culot Exp $ */
/* /*
* Calcurse - text-based organizer * Calcurse - text-based organizer
@ -31,12 +31,13 @@
#include "i18n.h" #include "i18n.h"
#include "vars.h" #include "vars.h"
#include "wins.h"
/* /*
* General signal handling routine. * General signal handling routine.
* Catch return values from children (user-defined notification commands). * Catch return values from children (user-defined notification commands).
* This is needed to avoid zombie processes running on system. * This is needed to avoid zombie processes running on system.
* Also catch CTRL-C (SIGINT) to exit properly. * Also catch CTRL-C (SIGINT), and SIGWINCH to resize screen automatically.
*/ */
static void static void
signal_handler(int sig) signal_handler(int sig)
@ -46,6 +47,9 @@ signal_handler(int sig)
while (waitpid(WAIT_MYPGRP, NULL, WNOHANG) > 0) while (waitpid(WAIT_MYPGRP, NULL, WNOHANG) > 0)
; ;
break; break;
case SIGWINCH:
wins_reset();
break;
} }
} }
@ -61,6 +65,14 @@ sigs_init(struct sigaction *sa)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
sa->sa_handler = signal_handler;
sa->sa_flags = 0;
sigemptyset(&sa->sa_mask);
if (sigaction(SIGWINCH, sa, NULL) != 0) {
perror("sigaction");
exit(EXIT_FAILURE);
}
sa->sa_handler = SIG_IGN; sa->sa_handler = SIG_IGN;
sa->sa_flags = 0; sa->sa_flags = 0;
sigemptyset(&(sa->sa_mask)); sigemptyset(&(sa->sa_mask));