#30154 [Com]: php stdin control under windows dos prompt

From: Date: Mon, 20 Sep 2004 13:44:49 +0000
Subject: #30154 [Com]: php stdin control under windows dos prompt
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-66455@lists.php.net to get a copy of this message
ID: 30154 Comment by: xxmettedraq at comcast dot net Reported By: xxmettedraqxx at comcast dot net Status: Open Bug Type: CGI related Operating System: windows xp PHP Version: 5.0.1 New Comment: function getStdI() { static $pStdn, $pArr; if(!$pStdn || !$pArr) { $pStdn = fopen("php://stdin", "r"); $pArr = array($pStdn); } if (false === ($num_changed_streams = stream_select($pArr, $write = NULL, $except = NULL, 0))) { print("\$ 001 Socket Error : UNABLE TO WATCH STDIN.\n"); return FALSE; } elseif ($num_changed_streams > 0) { return fgets($pStdn, 1024); } } // end function getStdI I found this on the internet.. stream_select fails for me so I'm assuming this is not possible under windows even in version 5.0.1 of php and I'm going to try again under cygwin. If there is anything I can do to help code this bug/ability out. Let me know. I know C/C++ and assembly but I am not familiar with the PHP source code.. Thank you. Previous Comments: ------------------------------------------------------------------------ [2004-09-19 16:35:07] xxmettedraqxx at comcast dot net Description: ------------ I'm not sure if non-blocking mode works under windows xp.. I can't seem to process anything while waiting for user input.. it's possible that I just do not know how to code this in php and it is my fault. Although I searched for several days before posting this. Can anyone help me out on this? p.s. please email me if I don't respond.. I might loose track of this bug if I'm not contacted in some way. Thank you. Reproduce code: --------------- set_time_limit (0); $fp_stdin = fopen("php://stdin", "rb"); stream_set_blocking($fp_stdin, false); ob_implicit_flush (); $input = get_line($fp_stdin); function get_line($fp) { $input = ""; $char = ""; do { if (($char = @fread($fp,1)) !== false) { $input .= $char; if ($char == "\n") { break; } $char = ""; } else { echo "testing..\n"; } } while(true); return $input; }; // end function get_line Expected result: ---------------- I should be able to see the word testing until the user types something.. as in.. say I typed in "shutdown".. then the program would exit... after testing my input.. the testing is a substitute for checking telnet connections to allow for user input from the keyboard and at the same time run through other processes. Actual result: -------------- it waits for user input. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30154&edit=1

« previous php.bugs (#66455) next »