pcntl_wait / pcntl_waitpid: Document the rusage parameter (fixes #861) - #4917
Conversation
TimWolla
left a comment
There was a problem hiding this comment.
pcntl_waitid already has the parameter documented. Can you align the explanation: https://www.php.net/manual/en/function.pcntl-waitid.php?
Done |
TimWolla
left a comment
There was a problem hiding this comment.
Except for the example this LGTM. Perhaps it makes sense to split the example off in another PR?
| print "PARENT pcntl_waitpid: No exited children.\n"; | ||
| } else { | ||
| print "PARENT pcntl_waitpid: Child PID {$deadPid} exited with status: " | ||
| . pcntl_wexitstatus($status) ."\n"; |
There was a problem hiding this comment.
The documentation for wexitstatus says:
This function is only useful if pcntl_wifexited() returned true.
So, is a wifexited call missing here? Looking more carefully at the example, it uses quite a few functions from the pcntl extension. It might make sense to include it in https://www.php.net/manual/en/pcntl.example.php instead.
| &reftitle.examples; | ||
| <para> | ||
| <example> |
| <varlistentry> | ||
| <term><parameter>resource_usage</parameter></term> | ||
| <listitem> | ||
| <para> | ||
| The <parameter>resource_usage</parameter> parameter is set to an | ||
| associative <type>array</type> 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. For | ||
| information on the contents see <function>getrusage</function>. | ||
| </para> | ||
| </listitem> | ||
| </varlistentry> |
There was a problem hiding this comment.
Considering how often this is repeated, an XInclude or XML entity to have consistent wording would be better
The wait6 / raw waitid wording only applies to pcntl_waitid. pcntl_wait uses wait3() under HAVE_WAIT3 and pcntl_waitpid uses wait4() under HAVE_WAIT4, so both fill resource_usage on Linux and macOS as well. Also document that the array is emptied when no child is reaped, drop the pcntl_waitpid entry duplicated in the pcntl_wait seealso list, guard pcntl_wexitstatus() with pcntl_wifexited() in the example, print the errno instead of the constant -1 return, unwrap the example from its para and split the inline-only paras into simparas for the style check.
b9cb0c2 to
945c849
Compare
No description provided.