Last active
June 26, 2019 03:04
-
-
Save jstaursky/b15052dede94802aabff55cc815f58d7 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
#include <stdio.h> | |
#include <stdlib.h> // void exit( int exit_code) | |
#include <signal.h> // void (*signal( int sig, void (*handler) (int))) (int) | |
// handler must be of the form "void func (int sig)" | |
// signal_code is useful in-cases where handler is used for more than one signal | |
void handler (int signal_code) | |
{ | |
printf ("\nHello World!\n"); | |
printf ("signal value: %d\n", signal_code); | |
exit (1); | |
} | |
int main (int argc, char *argv[]) | |
{ | |
// register handler function to handle signal SIGINT = interrupt from | |
// keyboard (^C) | |
signal (SIGINT, handler); | |
while (1) | |
; // Busy Wait until application receives SIGINT. | |
// Never reached. | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment