|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-04 08:06 UTC] mike at silverorange dot com
Description:
------------
When using stream_select() on pipes returned by proc_open() in Windows, input streams that are not ready are returned in the modified $read array.
Reproduce code:
---------------
<?php
$pipes = array();
$proc = proc_open('c:/progra~1/gnu/gnupg/gpg.exe', array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w')), $pipes, null, $_ENV);
if ($proc !== false) {
$write = array($pipes[0]);
$read = array($pipes[1], $pipes[2]);
$except = null;
$changed = stream_select($read, $write, $except, null);
if ($changed) {
print_r($read);
print_r($write);
}
proc_close($proc);
}
?>
Expected result:
----------------
The read array will be empty and the write array will contain stdin.
Actual result:
--------------
The read array contains stdin and the write array contains stdout and stderr. The stdout and stderr streams have no data ready and fread() will block indefinitely.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 04:00:01 2025 UTC |
function loadModule ( $moduleName ) { $descriptorspec = array( 0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("file", "errors.txt", "a") ); $module = proc_open ( 'I:\httpd\php\php.exe I:\httpd\php-irc-bot\module.' . $moduleName . '.php', $descriptorspec, $pipes, NULL, array ( 'RUNFIRST' => true ) ); $this -> runningModules[$moduleName] = $module; echo "Registered new module: $moduleName\r\n"; $this -> pipes[$moduleName] = $pipes; } ... few code ... foreach ( $this -> pipes as $module => $pipes ) { fwrite ( $pipes[0], $msg ); $forChange[] = $pipes[1]; } $r = NULL; $e = NULL; $sock_change = stream_select ( $forChange, $r, $e, 0, 20 ); if ( $sock_change > 0 && $sock_change !== false ) { foreach ( $forChange as $key => $stream ) { echo fread ( $stream, 4096 ); } } PHP 5.2.2, 5.2.8, 5.3 (Windows Vista 64bit, x86 build, running from CLI) still not working. After 3/4 of year still not fixed. PHP6 says some warnings, never seen before ("Cannot cast a filtered stream on this system", complete errors: http://clip2net.com/clip/m12051/1233956312-clip-16kb.png