signalTimer

simple timer using SIGALARM
git clone https://noulin.net/git/signalTimer.git
Log | Files | Refs | LICENSE

commit 76e6fc4ed6ebd399bdeea95c62a921ae6cb51f65
parent fd7152bda1826962040ae10913ed482a523b19af
Author: Remy Noulin <loader2x@gmail.com>
Date:   Sun, 16 Sep 2018 09:23:17 +0200

call old sigaction when SIGALRM triggers

package.yml   | 2 +-
signalTimer.c | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)

Diffstat:
Mpackage.yml | 2+-
MsignalTimer.c | 5++++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/package.yml b/package.yml @@ -1,6 +1,6 @@ --- name: signalTimer - version: 0.0.3 + version: 0.0.4 description: "simple timer using SIGALARM" bin: ./signalTimer.c repository: diff --git a/signalTimer.c b/signalTimer.c @@ -40,6 +40,7 @@ internal void alarmSigaction(int signal, siginfo_t *si, void *arg); static struct itimerval it_val; +internal struct sigaction oldsa; void initiateSignalTimer(signalTimert *self) { @@ -58,7 +59,7 @@ void initiateSignalTimer(signalTimert *self) { sigemptyset(&sa.sa_mask); sa.sa_sigaction = alarmSigaction; sa.sa_flags = SA_SIGINFO; - pTestErrorCmd(sigaction(SIGALRM, &sa, NULL) != 0, XFAILURE); + pTestErrorCmd(sigaction(SIGALRM, &sa, &oldsa) != 0, XFAILURE); } @@ -200,6 +201,8 @@ internal void setIntervalSignalTimer(signalTimert *self, u64 interval) { internal void alarmSigaction(int signal, siginfo_t *si, void *arg) { theSignalTimerAddr->callback(theSignalTimerAddr->args); + if (oldsa.sa_sigaction) oldsa.sa_sigaction(signal, si, arg); + if (oldsa.sa_handler) oldsa.sa_handler(signal); } /* TODO add method implementations */