Prefer sigsuspend(2) over pause(2)

As OpenBSD manual for pause(3) stated, this function is made obsolete by
sigsuspend(2).

We may think it will be removed in future for this *nix.

On linux, this require defining _POSIX_C_SOURCE to 1.
This commit is contained in:
Simon Lieb 2016-10-21 13:39:01 +02:00 committed by Ivan Tham
parent 0af77c1282
commit 22f35d5af4
2 changed files with 3 additions and 2 deletions

View File

@ -16,7 +16,7 @@ INCS+= `pkg-config --cflags libnotify`
LIBS+= `pkg-config --libs libnotify`
# flags
CPPFLAGS = -DVERSION=\"${VERSION}\"
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_POSIX_C_SOURCE
CFLAGS += -g -std=c99 -pedantic -Wall -Os ${INCS} ${DEFS} ${CPPFLAGS}
LDFLAGS += -g ${LIBS}

3
spt.c
View File

@ -108,6 +108,7 @@ usage(void)
int
main(int argc, char *argv[])
{
sigset_t *emptymask = 0;
suspend = 0;
ARGBEGIN {
@ -135,7 +136,7 @@ main(int argc, char *argv[])
timecount = 0;
while (timecount < timers[i].tmr)
if (suspend)
pause();
sigsuspend(emptymask);
else {
sleep(1);
timecount++;