@@ -17,8 +17,7 @@ $is_child = isset($argv[1]);
17
17
if ($ is_child ) {
18
18
function handler ($ evt )
19
19
{
20
- echo "\nCaught " . get_evt_name ($ evt ), ", wait, wait ...! \n" ;
21
- exit ;
20
+ exit (3 );
22
21
}
23
22
24
23
sapi_windows_set_ctrl_handler ('handler ' );
@@ -46,10 +45,21 @@ if ($is_child) {
46
45
echo "Sending " , get_evt_name ($ evt ), " to child $ child_pid \n" ;
47
46
$ ret = sapi_windows_generate_ctrl_event ($ evt , $ child_pid );
48
47
49
- echo "Child said: \"" , trim (fread ($ pipes [1 ], 48 )), "\"\n" ;
50
-
51
48
echo ($ ret ? "Successfully " : "Unsuccessfuly " ), " sent " , get_evt_name ($ evt ), " to child $ child_pid \n" ;
52
49
50
+ $ max = 5000 ; $ total = 0 ; $ step = 100 ;
51
+ while (proc_get_status ($ proc )["running " ] && $ max > $ total ) {
52
+ usleep ($ step );
53
+ $ total += $ step ;
54
+ }
55
+
56
+ $ status = proc_get_status ($ proc );
57
+ if ($ status ["running " ]) {
58
+ echo "Child $ child_pid didn't exit after $ {max}us \n" ;
59
+ } else {
60
+ echo "Child $ child_pid exit with status " , $ status ["exitcode " ], " after $ {total}us \n" ;
61
+ }
62
+
53
63
proc_close ($ proc );
54
64
}
55
65
@@ -70,6 +80,6 @@ Started child %d
70
80
Running `tasklist /FI "PID eq %d" /NH` to check the process indeed exists:
71
81
php.exe%w%d%s1%s
72
82
Sending CTRL+C to child %d
73
- Child said: "Caught CTRL+C, wait, wait ...!"
74
83
Successfully sent CTRL+C to child %d
84
+ Child %d exit with status 3 after %dus
75
85
0 commit comments