com php-src: Merge branch 'PHP-7.4': sapi/cli/tests/sapi_wind ows_set_ctrl_handler.phpt

From: Date: Wed, 29 Jul 2020 10:47:41 +0000
Subject: com php-src: Merge branch 'PHP-7.4': sapi/cli/tests/sapi_wind ows_set_ctrl_handler.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112431@lists.php.net to get a copy of this message
Commit: 687e14ddc220195390a68ce6ea43b0f55bad4aff Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 29 Jul 2020 12:47:41 +0200 Parents: ae8dea0b10663aee9aea07c27e9c7ec8cd85ad81 f8792443a2c4c69d58a62ad32f2cbc3948774f53 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=687e14ddc220195390a68ce6ea43b0f55bad4aff Log: Merge branch 'PHP-7.4' * PHP-7.4: Prevent test case from stalling Changed paths: MM sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt Diff: diff --cc sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt index dbb02a00bd,4f1963d052..09030c90f8 --- a/sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt +++ b/sapi/cli/tests/sapi_windows_set_ctrl_handler.phpt @@@ -15,52 -15,54 +15,54 @@@ $is_child = isset($argv[1]) if ($is_child) { - function handler($evt) - { - exit(3); - } + function handler($evt) + { + exit(3); + } - sapi_windows_set_ctrl_handler('handler'); + sapi_windows_set_ctrl_handler('handler'); - while(1) usleep(100); + while(1) usleep(100); } else { - $cmd = PHP_BINARY . " -n " . $argv[0] . " 1"; - $spec = [0 => ["pipe", "r"], 1 => ["pipe", "w"]]; + $cmd = PHP_BINARY . " -n " . $argv[0] . " 1"; + $spec = [0 => ["pipe", "r"], 1 => ["pipe", "w"]]; - $proc = proc_open($cmd, $spec, $pipes, NULL, NULL, ["bypass_shell" => true, "create_process_group" => true]); + $proc = proc_open($cmd, $spec, $pipes, NULL, NULL, ["bypass_shell" => true, "create_process_group" => true]); - if (!is_resource($proc)) { - die("Failed to start child. "); - } + if (!is_resource($proc)) { + die("Failed to start child. "); + } - $child_pid = proc_get_status($proc)["pid"]; - echo "Started child $child_pid\n"; - usleep(300); + $child_pid = proc_get_status($proc)["pid"]; + echo "Started child $child_pid\n"; + usleep(300); - $cmd = "tasklist /FI \"PID eq $child_pid\" /NH"; - echo "Running $cmd to check the process indeed exists:\n"; - echo trim(shell_exec($cmd)) . "\n"; + $cmd = "tasklist /FI \"PID eq $child_pid\" /NH"; + echo "Running $cmd to check the process indeed exists:\n"; + echo trim(shell_exec($cmd)) . "\n"; - $evt = PHP_WINDOWS_EVENT_CTRL_C; - echo "Sending ", get_evt_name($evt), " to child $child_pid\n"; - $ret = sapi_windows_generate_ctrl_event($evt, $child_pid); + $evt = PHP_WINDOWS_EVENT_CTRL_C; + echo "Sending ", get_evt_name($evt), " to child $child_pid\n"; + $ret = sapi_windows_generate_ctrl_event($evt, $child_pid); - echo ($ret ? "Successfully" : "Unsuccessfuly"), " sent ", get_evt_name($evt), " to child $child_pid\n"; + echo ($ret ? "Successfully" : "Unsuccessfuly"), " sent ", get_evt_name($evt), " to child $child_pid\n"; - $max = 5000; $total = 0; $step = 100; - while(proc_get_status($proc)["running"] && $max > $total) { - usleep($step); - $total += $step; - } + $max = 5000; $total = 0; $step = 100; + while(proc_get_status($proc)["running"] && $max > $total) { + usleep($step); + $total += $step; + } - $status = proc_get_status($proc); - if ($status["running"]) { - echo "Child $child_pid didn't exit after ${max}us\n"; + $status = proc_get_status($proc); + if ($status["running"]) { + echo "Child $child_pid didn't exit after ${max}us\n"; + foreach ($pipes as $pipe) { + fclose($pipe); + } + proc_terminate($proc); - } else { - echo "Child $child_pid exit with status ", $status["exitcode"], " after ${total}us\n"; - } + } else { + echo "Child $child_pid exit with status ", $status["exitcode"], " after ${total}us\n"; + } - - proc_close($proc); } function get_evt_name(int $evt) : ?string

« previous php.cvs (#112431) next »