Skip to content
BSD syscall#7

svc · unix #7

wait4

Waits for a child process to change state, returning status and rusage.

Prototype

int wait4(int pid, user_addr_t status, int options, user_addr_t rusage);

Returns: int

Arguments

NameTypeDirDescription
pidint-
statususer_addr_t-
optionsint-
rusageuser_addr_t-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard7
xnu-1486.2.117
xnu-1504.15.37
xnu-1504.3.127
xnu-1504.7.47
xnu-1504.9.177
xnu-1504.9.267
xnu-1504.9.377

Notes

BSD-flavoured reaper that backs waitpid() in libc. Options include WNOHANG for polling and WUNTRACED/WCONTINUED to observe job-control stops. The rusage out-parameter is populated from the child's accumulated counters before its proc struct is freed.

Detection

DTrace syscall::wait4:return shows the reaped PID in arg0 and decoded status via WIFEXITED/WTERMSIG macros. Endpoint Security correlates the prior ES_EVENT_TYPE_NOTIFY_EXIT.

Related APIs

waitidforkposix_spawnexitkillgetrusage