waitpid의 wstatus상태값에 대한 문의

htiger의 이미지

프로그램의 종료를 기다리는 다음의 waitpid함수 이용하여 프로그램 종료 상태 확인시,

waitpid(child_pid, &status , 0);

status값을 출력해 보면 segment fault에 대한 이 11 or 139로 확인 됩니다. 두 가지 모두 segment fault에 대한 사항으로 설명들이 있는 것은 확인하였는데요( WTERMSIG(status)로 확인 ). 11(0x0b)와 139(0x8b)의 정확한 차이를 알고 싶습니다.

감사합니다.

jick의 이미지

찾아보니까 이건 것 같네요:

WCOREDUMP(status)
returns true if the child produced a core dump. This macro should only be employed if WIFSIGNALED returned true. This macro is not specified in POSIX.1-2001 and is not available on some UNIX implementations (e.g., AIX, SunOS). Only use this enclosed in #ifdef WCOREDUMP ... #endif.

#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
 
int main()
{
    printf("%d\n", (int) WCOREDUMP(11));
    printf("%d\n", (int) WCOREDUMP(139));
    return 0;
}
 
결과:
0
128