pcntl_waitpid
Waits on or returns the status of a forked child.
pcntl_waitpid Function synopsis
pcntl_waitpid(
int $process_id,
&$status,
int $flags = 0,
&$resource_usage = []
): int
Parameters
$process_id
Typeint
The value of $process_id can be one of the following:
$status
Passed by reference
pcntl_waitpid will store status information
in the $status parameter which can be
evaluated using the following functions:
pcntl_wifexited,
pcntl_wifstopped,
pcntl_wifsignaled,
pcntl_wexitstatus,
pcntl_wtermsig and
pcntl_wstopsig.
$flags
OptionalTypeintDefault value0
The value of $flags is the value of zero
or more of the following two global constants
OR'ed together:
$resource_usage
Passed by reference, OptionalDefault value[]
Note that the parameters
$statusand$resource_usageare passed by reference, and contain additional/updated context data that may be useful.
Return value
Typeint
pcntl_waitpid returns the process ID of the
child which exited, -1 on error or zero if WNOHANG was used and no
child was available
Changes to the pcntl_waitpid Function
PHP 8.0
- Return type added:
int - Parameter name of parameter #1 changed:
$pidto$process_id - Parameter type added for parameter #1 (
$process_id):int - Parameter name of parameter #3 changed:
$optionsto$flags - Parameter type added for parameter #3 (
$flags):int - Parameter default value added for position #3 (
$flags):0 - Parameter name of parameter #4 changed:
$rusageto$resource_usage - Parameter default value added for position #4 (
$resource_usage):[]
pcntl_waitpid(
- $pid,
+ int $process_id,
&$status,
- $options,
+ int $flags = 0,
- &$rusage
+ &$resource_usage = []
- )
+ ): int PHP 7.0
- Optional parameter added - #4:
&$rusage
pcntl_waitpid(
$pid,
&$status,
- $options
+ $options,
+ &$rusage
) pcntl_waitpid Function Availability
pcntl_waitpid Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |