pcntl_waitid

FunctionParams changed in PHP 8.5

Waits for a child process to change state.

PHP 5
PHP 7
PHP 8.0
PHP 8.1-8.2
PHP 8.3
PHP 8.4
Added
PHP 8.5
Improved
PHP 8.6

pcntl_waitid Function synopsis

pcntl_waitid(
    int $idtype = P_ALL,
    ?int $id = null,
    &$info = [],
    int $flags = WEXITED,
    &$resource_usage = []
  ): bool

Parameters

$idtype

OptionalTypeintDefault valueP_ALL

$id

OptionalType?intDefault valuenull

$info

Passed by reference, OptionalDefault value[]

The $info parameter is set to an array containing information about the signal.

$flags

OptionalTypeintDefault valueWEXITED

The value of $flags is the value of zero or more of the following constants OR'ed together:

$resource_usage

Passed by reference, OptionalDefault value[]

The $resource_usage parameter is set to an array containing resource usage statistics from the child process.

  This is supported either if the wait6 system call is available
  (e.g. on FreeBSD), or on Linux through the raw waitid system call.

Note that the parameters $info and $resource_usage are passed by reference, and contain additional/updated context data that may be useful.

Return value

Typebool

pcntl_waitid returns true if WNOHANG was specified and status is not available for any process specified by $idtype and $id.

pcntl_waitid returns true due to the change of state of one of its children.

Otherwise, false is returned and pcntl_get_last_error can be used to get the errno error number.

Once an `errno` error number has been obtained,
[`pcntl_strerror`](/codex/pcntl_strerror) can be used to get the text message
associated with it.

Changes to the pcntl_waitid Function

PHP 8.5

  • Optional parameter added - #5: &$resource_usage = []
 pcntl_waitid(
     int $idtype = P_ALL,
     ?int $id = null,
     &$info = [],
-    int $flags = WEXITED
+    int $flags = WEXITED,
+    &$resource_usage = []
   ): bool

PHP 8.4

  • Function added

pcntl_waitid Function Availability

PHP VersionAvailability
PHP 8.6Future Release Yes
PHP 8.5Upcoming Release Yes
PHP 8.4Supported (Latest) Yes
PHP 8.3Supported No
PHP 8.2Security-Fixes Only No
PHP 8.1Security-Fixes Only No
PHP 8.0Unsupported No
PHP 7.4Unsupported No
PHP 7.3Unsupported No
PHP 7.2Unsupported No
PHP 7.1Unsupported No
PHP 7.0Unsupported No
PHP 5.6Unsupported No
PHP 5.5Unsupported No
PHP 5.4Unsupported No
PHP 5.3Unsupported No