자식 프로세스를 생성하고 즉시 종료하면 (_exit()) 대기를 수행하고 상태를 확인하려고합니다. 이제 if/else 구문의 'else'지점에서 WIFSIGNALED를 확인해야하는지 궁금합니다. 내가 이해할 수있는 한, 내가 기다림을하면, a) 오류가 발생할 수 있었고 (-1), 자식이 exit() 또는 _exit()에 의해 정상적으로 종료 될 수 있었거나, 신호가 없으므로 수표는 생략 할 수 있습니다.wait() 후 상태 확인
//remainder omitted
int status;
pid_t t_pid = wait(&status);
if (t_pid == -1) {
perror("wait");
exit(EXIT_FAILURE);
}
if (WIFEXITED(status)) {
printf("child terminated normally, status = %d\n",
WEXITSTATUS(status)
);
} else { // <-- do it have to check for WIFSIGNALED() here?
printf("child was terminated by a signal, signum = %d\n",
WTERMSIG(status)
);
}
+1 좋은 링크 ^^ – helpermethod