2014-10-15 1 views
1

Linux에 익숙하지 않습니다. 자식 프로세스를 기다리기 위해 waitid()를 사용하려고합니다. 나는 gcc를 사용하여 다음 줄을 포함하여 파일을 컴파일 할 때 다음 오류가 생성 된waitid() 및 P_PID로 컴파일 할 수 없습니다.

id_t cpid = fork(); 
siginfo_t status; 
waitid(P_PID, cpid, &status, WEXITED); 

을 :

error: ‘P_PID’ undeclared (first use in this function) 
나는 다음과 같은 라이브러리를 포함

:

#include <sys/types.h> 
#include <unistd.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <errno.h> 
#include <signal.h> 
#include <string.h> 
#include <time.h> 

내가습니까을 뭔가보고 싶니?

WIFSIGNALED()을 사용하여 siginfo_t에서 정보를 검색하려면 어떻게해야합니까?

+1

['waitid' 참고서 (http://pubs.opengroup.org/onlinepubs/9699919799/functions/waitid.html)를 읽고 싶을 수도 있습니다. 올바른 헤더 파일을 포함하고 있지 않습니다. –

+0

waitid()의 매뉴얼 페이지에 따르면 waitid()의 첫 번째 인수는 P_PID 또는 P_ALL 또는 P_GID 여야하며 waitid()의 사용법을 오해 했습니까? – user3545752

+0

@ user3545752 :'#include ' – Haris

답변

1

<sys/wait.h>을 포함하고 _XOPEN_SOURCE, as documented in the manual을 정의해야합니다.

WIFSIGNALED 매크로는 wait, waitpid 또는 waitid에서 가져온 정수 상태와 함께 사용해야합니다. waitpid의 경우 구조의 si_status 구성원으로 상태를 사용할 수 있습니다. 즉, , info은 이전에 waitid()에 전달한 주소가 siginfo_t 인 구조입니다.

+0

Thx! 나는 내가 을 포함하지 않았다는 것을 깨닫지 못했다. – user3545752