Bug #49139 [Com]: proc_open requires double quotes

From: Date: Fri, 23 Apr 2010 06:46:54 +0000
Subject: Bug #49139 [Com]: proc_open requires double quotes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-149807@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=49139&edit=1

 ID:               49139
 Comment by:       David dot Gausmann at measx dot com
 Reported by:      david dot gausmann at measx dot com
 Summary:          proc_open requires double quotes
 Status:           Open
 Type:             Bug
 Package:          Program Execution
 Operating System: win32 only - Windows XP SP3
 PHP Version:      5.3.0

 New Comment:

This is the same problem as mine:

$Command = '""c:\program files\doxygen\bin\doxygen.exe"
"C:\fred\doxyfile""';

$DescriptorSpecification = array
(
   0 => array('pipe', 'r'),
   1 => array('pipe', 'w'),
   2 => array('pipe', 'w')
);

$Resource = proc_open($Command, $DescriptorSpecification, $Pipes, null,
$_ENV);

Works fine (because it has the nasty double quotes around everything).


Previous Comments:
------------------------------------------------------------------------
[2010-04-23 02:22:47] xandrani at googlemail dot com

The double backward slashes didn't show correctly... but they are in my
code.

------------------------------------------------------------------------
[2010-04-23 02:20:33] xandrani at googlemail dot com

Something similar fails for me... but even worse!

$Command = '"c:\program files\doxygen\bin\doxygen.exe"
"C:\fred\doxyfile"'

$DescriptorSpecification = array
(
   0 => array('pipe', 'r'),
   1 => array('pipe', 'w'),
   2 => array('pipe', 'w')
);

$Resource = proc_open($Command, $DescriptorSpecification, $Pipes, null,
$_ENV);

I get the error:
'c:\program' is not recognized as an internal or external command,
operable program or batch file.

This works on exec() so not sure what's going on.

------------------------------------------------------------------------
[2009-08-03 13:09:56] david dot gausmann at measx dot com

Description:
------------
The command, which shall be executed via proc_open, must be put in
double quotes.
This bug was on functions like system, exec, ...
It seems not to be fixed on proc_open.

Reproduce code:
---------------
--- script1.php ---
<?php

  //Works fine
  echo "1.\r\n";
  system('"C:\php\php.exe" "C:\php\script2.php"');
  
  //FAILS!
  echo "2.\r\n";
  $arPipes = array();
  $rProcess = proc_open('"C:\php\php.exe" "C:\php\script2.php"', 
                  array(array('pipe', 'r'), array('pipe',
'w'),
array('pipe', 'w')), $arPipes);
  if($rProcess !== false)
  {
    $nExitCode = -1;
    do
    {
      while(!feof($arPipes[1]))
      {
        echo fread($arPipes[1], 1024);
        flush();
      }
      $array = proc_get_status($rProcess);
      if(!$array)
        break;
    } while($array['running']);
    fclose($arPipes[0]);
    fclose($arPipes[1]);
    fclose($arPipes[2]);
    proc_close($rProcess);
  }
  
  //Works fine (double quotes added)
  echo "3.\r\n";
  $arPipes = array();
  $rProcess = proc_open('""C:\php\php.exe"
"C:\php\script2.php""', 
                  array(array('pipe', 'r'), array('pipe',
'w'),
array('pipe', 'w')), $arPipes);
  if($rProcess !== false)
  {
    $nExitCode = -1;
    do
    {
      while(!feof($arPipes[1]))
      {
        echo fread($arPipes[1], 1024);
        flush();
      }
      $array = proc_get_status($rProcess);
      if(!$array)
        break;
    } while($array['running']);
    fclose($arPipes[0]);
    fclose($arPipes[1]);
    fclose($arPipes[2]);
    proc_close($rProcess);
  }


?>
---script2.php---
<?php

  echo "Lorem ipsum\r\n";
  exit(0);

?>

Expected result:
----------------
1.
Lorem ipsum
2.
Lorem ipsum
3.

The third call of proc_open should fail, the second one should work.

Actual result:
--------------
1.
Lorem ipsum
2.
3.
Lorem ipsum

The second call of proc_open should fails, but the third one works.


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



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


Thread (9 messages)

« previous php.bugs (#149807) next »