Markdown Format | JSON API | MCP Server Tool
Wait for the termination of arbitrary processes.
waitpid {{pid1 pid2 ...}}waitpid {{-t|--timeout}} {{n}} {{pid1 pid2 ...}}waitpid {{-e|--exited}} {{pid1 pid2 ...}}waitpid {{-c|--count}} {{n}} {{pid1 pid2 ...}}waitpid {{-h|--help}} waitpid PID,FLAGS
Waits for a particular child process to terminate and returns
the pid of the deceased process, or -1 if there is no such child
process. A non-blocking wait (with WNOHANG in FLAGS) can return
0 if there are child processes matching PID but none have
terminated yet. The status is returned in $? and
"${^CHILD_ERROR_NATIVE}".
A PID of 0 indicates to wait for any child process whose process
group ID is equal to that of the current process. A PID of less
than -1 indicates to wait for any child process whose process
group ID is equal to -PID. A PID of -1 indicates to wait for any
child process.
If you say
use POSIX ":sys_wait_h";
my $kid;
do {
$kid = waitpid(-1, WNOHANG);
} while $kid > 0;
or
1 while waitpid(-1, WNOHANG) > 0;
then you can do a non-blocking wait for all pending zombie
processes (see "WAIT" in POSIX). Non-blocking wait is available
on machines supporting either the waitpid(2) or wait4(2)
syscalls. However, waiting for a particular pid with FLAGS of 0
is implemented everywhere. (Perl emulates the system call by
remembering the status values of processes that have exited but
have not been harvested by the Perl script yet.)
Note that on some systems, a return value of -1 could mean that
child processes are being automatically reaped. See perlipc for
details, and for other examples.
Portability issues: "waitpid" in perlport.
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 19:31 @216.73.216.151 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)