Last active
March 1, 2021 16:15
-
-
Save kizilkayabayram/74a771102418d3d502ab1dc0e59cf425 to your computer and use it in GitHub Desktop.
C signal handling
This file contains hidden or 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 <signal.h> | |
| volatile sig_atomic_t stop; | |
| void inthand(int signum) | |
| { | |
| stop = 1; | |
| } | |
| int main(){ | |
| signal(SIGINT, inthand); // register signal handler | |
| while(!stop){ | |
| // do stuff | |
| } | |
| exit(0) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment