The waitid (2)

For further fine tuning and control, there is the waitid(2) system call as well (from Linux 2.6.9):

int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);

The first two parameters will in effect specify the children to wait upon:

waitid(2): 1st parameter: idtype Second parameter: id
P_PID Set to the PID of the child to wait (block) upon
P_PGID Wait upon any child whose process group ID (PGID) matches this number
P_ALL Wait upon any child (this parameter is ignored)

The fourth options parameter is similar to how it was used with the waitpid(2), but not identical; there are some additional options that can be passed along; again, it's a bitmask, not an absolute value: the WNOHANG and WCONTINUED

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.