I am new to Linux. I am trying to use waitid() to wait for a child process. When I try to compile a file including the following lines using gcc:
id_t cpid = fork();
siginfo_t status;
waitid(P_PID, cpid, &status, WEXITED);
The following error was generated:
error: ‘P_PID’ undeclared (first use in this function)
I included the following libraries:
#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>
Did I miss something?
Another question is that how can I use WIFSIGNALED()
to retrieve information from type siginfo_t
?