diff options
author | Leah Neukirchen <leah@vuxu.org> | 2022-01-27 14:53:15 +0100 |
---|---|---|
committer | Leah Neukirchen <leah@vuxu.org> | 2022-01-27 14:53:30 +0100 |
commit | 90073f35238082976573e5d6bc4e681bec20e30c (patch) | |
tree | 3640deaa8f024d63e77b4bab3810804b07b76fbb | |
parent | a7ead9fde1dd81d8fda7c828d2518c4326a8857f (diff) | |
download | snooze-90073f35238082976573e5d6bc4e681bec20e30c.tar.gz snooze-90073f35238082976573e5d6bc4e681bec20e30c.tar.xz snooze-90073f35238082976573e5d6bc4e681bec20e30c.zip |
sig_atomic_t should be used with volatile
-rw-r--r-- | snooze.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/snooze.c b/snooze.c index ed929c7..06f0d07 100644 --- a/snooze.c +++ b/snooze.c @@ -31,7 +31,7 @@ static int randdelay = 0; static int jitter = 0; static char *timefile; -static sig_atomic_t alarm_rang = 0; +static volatile sig_atomic_t alarm_rang = 0; static void wakeup(int sig) @@ -356,11 +356,11 @@ main(int argc, char *argv[]) printf("Snoozing until %s\n", isotime(tm)); // setup SIGALRM handler to force early execution - struct sigaction sa; + struct sigaction sa = { 0 }; sa.sa_handler = &wakeup; sa.sa_flags = SA_RESTART; sigfillset(&sa.sa_mask); - sigaction(SIGALRM, &sa, NULL); // XXX error handling + sigaction(SIGALRM, &sa, NULL); while (!alarm_rang) { now = time(0); |