Created
March 16, 2021 14:17
-
-
Save phire/726ee1f48ef8e2e5e4f0a8c9e4069489 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <signal.h> | |
#include <stdatomic.h> | |
#include <stdlib.h> | |
atomic_int count = 0; | |
void sig_handler(int signum) { | |
printf("Alarm %i\n", count++); | |
if (count == 3) { | |
exit(0); | |
} | |
alarm(1); | |
} | |
int main() { | |
signal(SIGALRM,sig_handler); | |
alarm(1); | |
for(;;) { | |
sleep(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment