printf(" after 5s SIGKILL will be passed and exit(1)\n");
printf(" SIGTERM - passes SIGTERM to command's process group\n");
printf(" after 1s SIGKILL will be passed and exit(1)\n");
+ printf(" SIGINT - handled like SIGTERM\n");
+ printf(" SIGQUIT - handled like SIGTERM\n");
}
static void sig_alrm_kill(int sig)
}
signal(SIGTERM, sig_term);
+ signal(SIGINT, sig_term);
+ signal(SIGQUIT, sig_term);
signal(SIGUSR1, sig_usr1);
signal(SIGALRM, sig_alrm_term);
alarm(maxtime);
int status;
pid_t pid = wait(&status);
if (pid != -1) {
- ret = WEXITSTATUS(status);
+ if (WIFEXITED(status)) {
+ ret = WEXITSTATUS(status);
+ }
} else if (errno == ECHILD) {
break;
}