Skip to content

Instantly share code, notes, and snippets.

@kizilkayabayram
Last active March 1, 2021 16:15
Show Gist options
  • Select an option

  • Save kizilkayabayram/74a771102418d3d502ab1dc0e59cf425 to your computer and use it in GitHub Desktop.

Select an option

Save kizilkayabayram/74a771102418d3d502ab1dc0e59cf425 to your computer and use it in GitHub Desktop.
C signal handling
#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