Skip to content

Instantly share code, notes, and snippets.

@stumped2
Created December 5, 2013 21:24
Show Gist options
  • Save stumped2/7814178 to your computer and use it in GitHub Desktop.
Save stumped2/7814178 to your computer and use it in GitHub Desktop.
void signalHandler(int signum, siginfo_t *info, void *ptr)
{
int status, i;
for (i = 0; i < processes; i++) {
kill(pidfor_signal[i], SIGKILL);
wait(&status);
}
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
/* Setting up signal handling */
//fprintf(stderr, "setting up signal\n");
memset(&act, 0, sizeof(act));
act.sa_sigaction = signalHandler;
act.sa_flags = SA_SIGINFO;
sigaction(SIGINT, &act, NULL );
sigaction(SIGQUIT, &act, NULL );
sigaction(SIGHUP, &act, NULL );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment