ID:               30154
 Updated by:       [EMAIL PROTECTED]
 Reported By:      xxmettedraqxx at comcast dot net
-Status:           Open
+Status:           Wont fix
 Bug Type:         CGI related
 Operating System: windows xp
 PHP Version:      5.0.1
 New Comment:

win32 console doesn't work the same way as a unix tty, so if this
works, I'll be really surprised.  The official line is that we're not
changing anything to make it happen at this time.

Secondly, you should be using the constant STDIN instead of
fopen('php://stdin') in PHP 5 and later.


Previous Comments:
------------------------------------------------------------------------

[2004-09-20 15:44:46] xxmettedraq at comcast dot net

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.

------------------------------------------------------------------------

[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

Reply via email to