--- name: waitpid status: documented runtime: pp source: src/runtime/pp/process.rs --- ```{index} single: waitpid; Perl built-in (pp runtime) ``` # waitpid ## Synopsis ```perl my $result = waitpid($pid, 0); # blocking wait my $result = waitpid($pid, WNOHANG); # non-blocking my $result = waitpid(-1, 0); # any child (like wait) ``` ## Description Waits for a specific child process to change state. Suspends the current process until the child identified by `$pid` terminates (or changes state, depending on flags). Sets `$?` to the wait status. Returns: - The PID of the terminated child on success - `0` if `WNOHANG` was specified and no child has exited yet - `-1` on error (e.g. no such child) When `$pid` is `-1`, waits for any child (equivalent to `wait()`). ## See also wait, fork, POSIX