|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-01-16 10:56 UTC] silencer at inbox dot ru
Description: ------------ stream_set_timeout can't be used for php://stdin (PHP executed as CGI, not Apache module). Bug #22837 describe same problem for PHP4 and promises "better support" in PHP5, but still don't working. Reproduce code: --------------- <?php $fp=fopen('php://stdin','r'); stream_set_timeout($fp,1) or die ('Failed'); echo 'Success'; ?> Expected result: ---------------- output "Success" Actual result: -------------- output "Failed" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 14:00:01 2025 UTC |
Still isn't working on PHP 5.3.9. [an0nym@localhost ~]$ php -v PHP 5.3.9 (cli) (built: Jan 11 2012 17:59:59) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies [an0nym@localhost ~]$ cat test.php <?php var_dump(stream_set_timeout(STDIN, 5)); [an0nym@localhost ~]$ php test.php bool(false) [an0nym@localhost ~]$ Workaround. [an0nym@localhost ~]$ cat input.php <?php for ($i = 0;; ++$i) { printf("%d\n", $i); sleep($i); } [an0nym@localhost ~]$ cat output.php <?php stream_set_blocking(STDIN, 0); $rss = array(STDIN); $wss = $ess = null; while (stream_select($rss, $wss, $ess, $argv[1])) { printf("%f\n", microtime(true)); echo stream_get_contents(STDIN); } printf("%f\n", microtime(true)); [an0nym@localhost ~]$ time php input.php | php output.php 5 1327087817.988219 0 1 1327087818.988345 2 1327087820.988437 3 1327087823.988534 4 1327087827.988655 5 1327087832.988771 6 1327087837.993888 real 0m21.023s user 0m0.017s sys 0m0.020s [an0nym@localhost ~]$