Created
February 23, 2017 02:40
-
-
Save makerj/a16dcb3e38d252df56c5cb43a14c9f3b 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
// once | |
struct sigaction sigact, old_sigact; | |
sigact.sa_handler = handler; | |
sigemptyset(&sigact.sa_mask); | |
sigact.sa_flags = SA_INTERRUPT; | |
sigaction(SIGALRM, &sigact, &old_sigact) < 0); | |
// somewhere loop | |
while(1) { | |
alarm(5); | |
blocking_task(); | |
alarm(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment