Skip to content

Instantly share code, notes, and snippets.

@W4RH4WK
Last active December 17, 2015 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save W4RH4WK/5536135 to your computer and use it in GitHub Desktop.
Save W4RH4WK/5536135 to your computer and use it in GitHub Desktop.
Signal Handler example
#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