Move to sigaction. Raise SIGWINCH on HUP for ncurses.

Thanks Bob for the sigaction suggestion!
This commit is contained in:
Christoph Lohmann 2020-12-20 17:20:03 +01:00
parent 6649dc02de
commit 0ebd046cc4
2 changed files with 18 additions and 7 deletions

View File

@ -12,7 +12,7 @@ MANPREFIX = ${PREFIX}/share/man
# use system flags. # use system flags.
CATPOINT_CFLAGS = ${CFLAGS} CATPOINT_CFLAGS = ${CFLAGS}
CATPOINT_CPPFLAGS = ${CPPFLAGS} CATPOINT_CPPFLAGS = ${CPPFLAGS} -D_DEFAULT_SOURCE
CATPOINT_LDFLAGS = ${LDFLAGS} -lncursesw CATPOINT_LDFLAGS = ${LDFLAGS} -lncursesw
# Gentoo # Gentoo
#CATPOINT_LDFLAGS = ${LDFLAGS} -lncursesw -ltinfow #CATPOINT_LDFLAGS = ${LDFLAGS} -lncursesw -ltinfow

View File

@ -61,18 +61,29 @@ reloadcurrentslide(int sig)
{ {
loadcurrentslide(slidefiles, currentslide); loadcurrentslide(slidefiles, currentslide);
if (sig == SIGHUP) if (sig == SIGHUP) {
raise(SIGWINCH); /* Redisplay slide. */ /* Make ncurses redisplay slide. */
if (raise(SIGWINCH) < 0)
err(1, "raise");
}
} }
void void
setsignal() setsignal()
{ {
signal(SIGHUP, reloadcurrentslide); struct sigaction sa;
signal(SIGINT, cleanup); memset(&sa, 0, sizeof(sa));
signal(SIGQUIT, cleanup); sigemptyset(&sa.sa_mask);
signal(SIGTERM, cleanup); sa.sa_flags = 0;
sa.sa_handler = cleanup;
sigaction(SIGINT, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sa.sa_handler = reloadcurrentslide;
sigaction(SIGHUP, &sa, NULL);
} }
int int