Created
July 30, 2015 10:54
-
-
Save lesovsky/8d0563302217c43bb9d0 to your computer and use it in GitHub Desktop.
Simple SIGINT handling.
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 <signal.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
void sig_handler(int signo) | |
{ | |
if (signo == SIGINT) { | |
printf("received SIGINT\n"); | |
exit(0); | |
} | |
} | |
int main(void) | |
{ | |
if (signal(SIGINT, sig_handler) == SIG_ERR) | |
printf("\ncan't catch SIGINT\n"); | |
while(1) | |
sleep(1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment