Last active
December 17, 2015 02:29
-
-
Save W4RH4WK/5536135 to your computer and use it in GitHub Desktop.
Signal Handler example
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 <signal.h> | |
#include <string.h> | |
void signalHandler(int sigNum) { | |
if (sigNum == SIGUSR1) { | |
// do stuff | |
} else if (sigNum == SIGUSR2) { | |
// do other stuff | |
} | |
} | |
int main(int argc, char* argv[]) { | |
struct sigaction sa; | |
memset(&sa, 0, sizeof(sa)); | |
sa.sa_handler = &signalHandler; | |
sigaction(SIGUSR1, &sa, NULL); | |
sigaction(SIGUSR2, &sa, NULL); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment