pcntl_wait
Waits on or returns the status of a forked child.
pcntl_wait Function synopsis
pcntl_wait(
&$status,
int $flags = 0,
&$resource_usage = []
): int
Parameters
$status
Passed by reference
pcntl_wait 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
If wait3 is available on your system (mostly BSD-style systems), you can
provide the optional $flags parameter. If this
parameter is not provided, wait will be used for the system call. If
wait3 is not available, providing a value for $flags
will have no effect. The value of $flags
is the value of zero or more of the following two 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_wait returns the process ID of the
child which exited, -1 on error or zero if WNOHANG was provided as an
option (on wait3-available systems) and no child was available.
Changes to the pcntl_wait Function
PHP 8.0
- Return type added:
int - Parameter name of parameter #2 changed:
$optionsto$flags - Parameter type added for parameter #2 (
$flags):int - Parameter default value added for position #2 (
$flags):0 - Parameter name of parameter #3 changed:
$rusageto$resource_usage - Parameter default value added for position #3 (
$resource_usage):[]
pcntl_wait(
&$status,
- $options,
+ int $flags = 0,
- &$rusage
+ &$resource_usage = []
- )
+ ): int PHP 7.0
- Optional parameter added - #3:
&$rusage
-pcntl_wait(&$status, $options)
+pcntl_wait(
+ &$status,
+ $options,
+ &$rusage
+ ) pcntl_wait Function Availability
pcntl_wait 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 |