ID:               35131
 Updated by:       [EMAIL PROTECTED]
 Reported By:      larryjadams at comcast dot net
-Status:           Open
+Status:           Assigned
 Bug Type:         *General Issues
 Operating System: WindowsXP Pro SP2
-PHP Version:      5.0.5
+PHP Version:      5CVS-2005-11-07 (snap)
 Assigned To:      wez
 New Comment:

Assigned to the author of this part.


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

[2005-11-07 02:09:19] larryjadams at comcast dot net

I have attempted to resolve the issue with the latest CVS.  However, it
does not solve the issue.  The stream_select fires right away even
though the popen does not have anything waiting on the pipe.

The version I tested was:
PHP 5.1.0RC5-dev (cli) (built: Nov  7 2005 00:47:12)
Copyright (c) 1997-2005 The PHP Group
Zend Engine v2.1.0-dev, Copyright (c) 1998-2005 Zend Technologies

I have noted some other issues that I will be opening separate tickets
one.

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

[2005-11-06 23:17:28] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip



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

[2005-11-06 23:09:04] [EMAIL PROTECTED]

Assigned to the author of this part.

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

[2005-11-06 22:07:19] larryjadams at comcast dot net

Description:
------------
If I call $my_fd = popen("mycommand", "rb"); to a function that
hangs/suspends and then subsquently call:

stream_select(...) using $read=array($my_fd) with a timeout, the
steam_select returns immediately, event if I have set $my_fd as
blocking using stream_set_blocking();

I would like stream_select to wait on output from the pipe prior to
firing, or to drive a timeout.

Thanks,

Larry Adams
The Cacti Group

Reproduce code:
---------------
if (function_exists("stream_select")) {
  if ($config["cacti_server_os"] == "unix")  {
    $fp = popen($command, "r");
  }else{
    $fp = popen($command, "rb");
  }

  /* set script server timeout */
  $script_timeout = read_config_option("script_timeout");

  /* establish timeout variables */
  $to_sec = floor($script_timeout/1000);
  $to_usec = ($script_timeout%1000)*1000;

  /* Prepare the read array */
  $read = array($fp);

  stream_set_blocking ($fp, 1);
  if (false === ($num_changed_streams = stream_select($read, $write =
NULL, $except = NULL, $to_sec, $to_usec))) {
    cacti_log("WARNING: SERVER POPEN Timed out.");
    $output = "U";
  }elseif ($num_changed_streams > 0) {
    $output = fgets($fp, 4096);
  }

  pclose($fp);
}else{
  $output = `$command`;
}

$command = a file with the following:

<?php sleep(20); echo "Hello:20.00\n"; ?>

The stream_select timeout is 5 seconds.


Expected result:
----------------
popen will be called, stream_select will block until timeout has
expired, the number of fd's changed will be 0 and my result will be as
expected.

Actual result:
--------------
stream_select returns immediately.


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


-- 
Edit this bug report at http://bugs.php.net/?id=35131&edit=1

Reply via email to