ID:               22999
 Updated by:       [EMAIL PROTECTED]
 Reported By:      phil at concretecomputing dot co dot uk
-Status:           Assigned
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: sun os
 PHP Version:      5CVS
 Assigned To:      wez
 New Comment:

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




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

[2003-10-08 07:23:47] [EMAIL PROTECTED]

Won't fix in PHP 4 (changes required are too messy to
introduce to stable branch), will fix in PHP 5.

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

[2003-04-17 13:37:25] michael at six dot de

We have the same issue with pclose()

Testcase:

<?php
$fp = popen("ls","r");
if ($fp) {
        while(! feof($fp)) {
                fgets($fp,1024);
        }
        $status = pclose($fp);
        print "pclose: status=$status\n";
}
?>

Most of the time $status is -1, sometimes 0.
PHP-4.3.2RC1, Solaris 7, --enable-sigchild

PHP is compiled with --enable-sigchild because the oracle client is
needed too, this was recommended in former bug descriptions. Is this
still the case for oracle?

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

[2003-04-01 05:00:37] [EMAIL PROTECTED]

This is a known issue when compiling with
--enable-sigchild.

I will see if it can be fixed.

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

[2003-04-01 04:17:36] phil at concretecomputing dot co dot uk

I'm trying to run a command via proc_open(). The command always
succeeds (exits with status of 0), so I would expect that proc_close()
would always return 0. Most of the time it does, but sometimes it
returns -1.

Here is a script which reproduces the problem. On my system, if you run
the script many times, most times the status reported will be 0, but
occasionally it will be -1.

<?

$inputArray = array(
  0 => array("pipe", "r"),                            // stdin is a
pipe that the child will read from
  1 => array("pipe", "w"),                            // stdout is a
pipe that the child will write to
  2 => array("pipe", "w")                             // stderr is a
pipe that the child will write to
);

$process = proc_open("ps -ef", $inputArray, $outputArray);             
  

if (is_resource($process)) {

  fclose($outputArray[0]);

  // Grab the output
  $output="";
  while(!feof($outputArray[1])) {
    $output .= fgets($outputArray[1], 1024);       
  }

  // Extract any error output
  $errorOutput = "";
  while(!feof($outputArray[2])) {
    $errorOutput .= fgets($outputArray[2], 1024);
  }

  // It is important that you close any pipes before calling
proc_close() in order to avoid a deadlock
  fclose($outputArray[1]);
  fclose($outputArray[2]);

  $status = proc_close($process);    

  echo "proc_close() return result: $status<br>\n";            
  echo "ps error output: [$errorOutput]<br>\n";
  echo "ps output: [$output]<br>\n";                 
}

echo "Done<br>\n";

?>


PHP is compiled as follows:

'./configure' '--with-apxs=/usr/local/apache1.3.27-nerens3.4/bin/apxs'
'--without-mysql' '--enable-track-vars' '--enable-sigchild'
'--with-oci8=/opt/oracle/product/9.0.1' '--enable-apc' '--with-xml'
'--with-expat-dir=/usr/local/expat' '--with-zlib=/usr/local/zlib'
'--with-curl=/usr/local/curl' '--with-mhash=/usr/local/mhash'
'--with-mcrypt=/usr/local/libmcrypt' 

I have tried to have a look at what is going on using truss and I think
it may be caused by another function within php doing a wait() and
getting the exit status for the child so that the wait() in proc_close
returns with ECHLD.

While testing using the above script, I have found that if I add a call
to sleep after the proc_open() call then proc_close() _always_ returns
-1 (and the sleep() call has no effect)

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


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

Reply via email to