Manual

- Overview
- Tutorials
- FAQs
- History / Changes
- License

Reference

- Language
- Functions
- Operators
- Special Variables
- Pragmas
- Utilities
- Internals
- Platform Specific

Modules

- A • B • C • D • E
- F • G • H • I • L
- M • N • O • P • S
- T • U • X

News / Blogs

- Perl Buzz
- Perl Iron Man
- Perlsphere
- Planet Perl
- TPF news
- Use Perl

See also

- CPAN
- Perl.org
- Perl.com
- Perl 5 Wiki
- Perl Jobs
- Perl Mongers
- Perl Monks

Contact

- Site designed and maintained by Jon Allen (JJ)
- http://perl.jonallen.info

- View the project page and FAQs

# waitpid

Perl 5 version 10.1 documentation
Go to top

# waitpid

Perl functions A-Z | Perl functions by category | The 'perlfunc' manpage

- 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. On some systems, a value of 0 indicates that there are processes still running. The status is returned in `$?` and `${^CHILD_ERROR_NATIVE}` . If you say

          use POSIX ":sys_wait_h";    #...    do {	$kid = waitpid(-1, WNOHANG);    } while $kid > 0;

  then you can do a non-blocking wait for all pending zombie processes. Non-blocking wait is available on machines supporting either the waitpid(2) or wait4(2) system calls. 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.

Recently read

Tools

- Preferences