File tree Expand file tree Collapse file tree 5 files changed +27
-8
lines changed Expand file tree Collapse file tree 5 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,12 @@ PHP 8.3 UPGRADE NOTES
27
27
. Class constants can now be accessed dynamically using the C::{$name} syntax.
28
28
RFC: https://wiki.php.net/rfc/dynamic_class_constant_fetch
29
29
. Executing proc_get_status() multiple times will now always return the right
30
- value. Previously, only the first call of the function returned the right
31
- value. Executing proc_close() after proc_get_status() will now also return
32
- the right exit code. Previously this would return -1.
30
+ value on posix systems. Previously, only the first call of the function
31
+ returned the right value. Executing proc_close() after proc_get_status() will
32
+ now also return the right exit code. Previously this would return -1.
33
+ Internally, this works by caching the result on posix systems. If you want
34
+ the old behaviour, you can check the "cached" key in the array returned by
35
+ proc_get_status() to check whether the result was cached.
33
36
34
37
========================================
35
38
2. New Features
Original file line number Diff line number Diff line change @@ -404,6 +404,10 @@ PHP_FUNCTION(proc_get_status)
404
404
running = wstatus == STILL_ACTIVE ;
405
405
exitcode = running ? -1 : wstatus ;
406
406
407
+ /* The status is always available on Windows and will always read the same,
408
+ * even if the child has already exited. This is because the result stays available
409
+ * until the child handle is closed. Hence no caching is used on Windows. */
410
+ add_assoc_bool (return_value , "cached" , false);
407
411
#elif HAVE_SYS_WAIT_H
408
412
wait_pid = waitpid_cached (proc , & wstatus , WNOHANG |WUNTRACED );
409
413
@@ -426,6 +430,8 @@ PHP_FUNCTION(proc_get_status)
426
430
* looking for either does not exist or is not a child of this process */
427
431
running = 0 ;
428
432
}
433
+
434
+ add_assoc_bool (return_value , "cached" , proc -> has_stored_exit_wait_status );
429
435
#endif
430
436
431
437
add_assoc_bool (return_value , "running" , running );
Original file line number Diff line number Diff line change @@ -24,11 +24,13 @@ echo "Done!\n";
24
24
25
25
?>
26
26
--EXPECTF--
27
- array(8 ) {
27
+ array(9 ) {
28
28
["command"]=>
29
29
string(14) "/bin/sleep 120"
30
30
["pid"]=>
31
31
int(%d)
32
+ ["cached"]=>
33
+ bool(false)
32
34
["running"]=>
33
35
bool(false)
34
36
["signaled"]=>
Original file line number Diff line number Diff line change @@ -13,11 +13,13 @@ var_dump(proc_get_status($p));
13
13
var_dump (proc_get_status ($ p ));
14
14
?>
15
15
--EXPECTF--
16
- array(8 ) {
16
+ array(9 ) {
17
17
["command"]=>
18
18
string(5) "false"
19
19
["pid"]=>
20
20
int(%d)
21
+ ["cached"]=>
22
+ bool(true)
21
23
["running"]=>
22
24
bool(false)
23
25
["signaled"]=>
@@ -31,11 +33,13 @@ array(8) {
31
33
["stopsig"]=>
32
34
int(0)
33
35
}
34
- array(8 ) {
36
+ array(9 ) {
35
37
["command"]=>
36
38
string(5) "false"
37
39
["pid"]=>
38
40
int(%d)
41
+ ["cached"]=>
42
+ bool(true)
39
43
["running"]=>
40
44
bool(false)
41
45
["signaled"]=>
Original file line number Diff line number Diff line change @@ -32,11 +32,13 @@ echo "Done!\n";
32
32
?>
33
33
--EXPECTF--
34
34
bool(true)
35
- array(8 ) {
35
+ array(9 ) {
36
36
["command"]=>
37
37
string(10) "/bin/sleep"
38
38
["pid"]=>
39
39
int(%d)
40
+ ["cached"]=>
41
+ bool(false)
40
42
["running"]=>
41
43
bool(true)
42
44
["signaled"]=>
@@ -51,11 +53,13 @@ array(8) {
51
53
int(0)
52
54
}
53
55
bool(true)
54
- array(8 ) {
56
+ array(9 ) {
55
57
["command"]=>
56
58
string(10) "/bin/sleep"
57
59
["pid"]=>
58
60
int(%d)
61
+ ["cached"]=>
62
+ bool(false)
59
63
["running"]=>
60
64
bool(false)
61
65
["signaled"]=>
You can’t perform that action at this time.
0 commit comments