Loop::run(static function () {
$process = new Process("diskpart");
yield $process->start();
});
Problem: app just stucks and does not stdout anything, using a timeout completely breaks the script execution:
Loop::run(static function () {
$process = new Process("diskpart");
yield timeout($process->start(), 5000);
});
Here an exception:
PHP Fatal error: Uncaught Exception: stream_select(): supplied resource is not a valid stream resource in C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\NativeDriver.php:79
Stack trace:
#0 [internal function]: Amp\Loop\NativeDriver->Amp\Loop\{closure}(2, 'stream_select()...', 'C:\\Users\\Admin\\...', 294, Array)
#1 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\NativeDriver.php(294): stream_select(Array, Array, NULL, 4, 0)
#2 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\NativeDriver.php(127): Amp\Loop\NativeDriver->selectStreams(Array, Array, 4)
#3 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\Driver.php(138): Amp\Loop\NativeDriver->dispatch(true)
#4 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\Driver.php(72): Amp\Loop\Driver->tick()
#5 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amp in C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\NativeDriver.php on line 79
Process finished with exit code 255
I found a possible solution to solve this problem, but I'm not good at creating PR.
By adding the following code to "lib/Internal/Windows/SocketConnector.php" at the end of the function "onProcessConnectTimeout" (I added after the line 367)
if ($handle->status === ProcessStatus::STARTING) {
Loop::cancel($handle->childPidWatcher);
$handle->pidDeferred->fail($error);
}
The problem is solved completely and now the output when running the first script:
PHP Fatal error: Uncaught Amp\Process\ProcessException: Failed to create child process: 740: Запрошенная операция требует повышения. in C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\process\lib\Internal\Windows\SocketConnector.php:359
Stack trace:
#0 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\NativeDriver.php(142): Amp\Process\Internal\Windows\SocketConnector->onProcessConnectTimeout('e', Object(Amp\Process\Internal\Windows\Handle))
#1 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\Driver.php(138): Amp\Loop\NativeDriver->dispatch(true)
#2 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop\Driver.php(72): Amp\Loop\Driver->tick()
#3 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\amp\lib\Loop.php(95): Amp\Loop\Driver->run()
#4 C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\test.php(17): Amp\ in C:\Users\Admin\Documents\win_install_stuff\windows_installer_v0\vendor\amphp\process\lib\Internal\Windows\SocketConnector.php on line 359
Process finished with exit code 255
PS. Sorry for a little machine translation, English is not my first language
The following code:
Problem: app just stucks and does not stdout anything, using a timeout completely breaks the script execution:
Here an exception:
I found a possible solution to solve this problem, but I'm not good at creating PR.
By adding the following code to "lib/Internal/Windows/SocketConnector.php" at the end of the function "onProcessConnectTimeout" (I added after the line 367)
The problem is solved completely and now the output when running the first script:
PS. Sorry for a little machine translation, English is not my first language