Use sigaction() instead, the handler will have this signature:
void (*sa_sigaction)(int, siginfo_t *, void *);
And it's passed the information you want in struct siginfo_t
, from the man page:
SIGCHLD fills in si_pid, si_uid, si_status, si_utime and si_stime, providing information about the child. The si_pid field is the process ID of the child
Note: you still need to wait()
on the child process of course, unless you use SA_NOCLDWAIT
.