Last active
May 16, 2017 18:34
-
-
Save tedz2usa/e8501c9297ad319cf21623aed1af0c69 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
http://stackoverflow.com/questions/1641182/how-can-i-catch-a-ctrl-c-event-c | |
#include <signal.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
void my_handler(int s){ | |
printf("Caught signal %d\n",s); | |
exit(1); | |
} | |
int main(int argc,char** argv) | |
{ | |
struct sigaction sigIntHandler; | |
sigIntHandler.sa_handler = my_handler; | |
sigemptyset(&sigIntHandler.sa_mask); | |
sigIntHandler.sa_flags = 0; | |
sigaction(SIGINT, &sigIntHandler, NULL); | |
pause(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment