php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22458 Proc_open hangs
Submitted: 2003-02-27 08:26 UTC Modified: 2003-02-27 15:45 UTC
From: jlondon at mail dot mcg dot edu Assigned:
Status: Not a bug Package: IIS related
PHP Version: 4.3.0 OS: Windows NT Server 4.0
Private report: No CVE-ID: None
 [2003-02-27 08:26 UTC] jlondon at mail dot mcg dot edu
proc_open hangs on the example that is in the manual.  Here is the code.

$descriptorspec = 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("file", "c:/temp/error-output.txt", "a"), // stderr is a
file to write to
);
$process = proc_open("c:\php\php.exe", $descriptorspec, $pipes);
if (is_resource($process)) {
    // $pipes now looks like this:
    // 0 => writeable handle connected to child stdin
    // 1 => readable handle connected to child stdout
    // Any error output will be appended to /tmp/error-output.txt

    fwrite($pipes[0], "<?php echo \"Hello World!\"; ?>" . chr(3));
    fclose($pipes[0]);

    while(!feof($pipes[1])) {
        echo fgets($pipes[1], 1024);
    }
    fclose($pipes[1]);
    // It is important that you close any pipes before calling
    // proc_close in order to avoid a deadlock
    $return_value = proc_close($process);

    echo "command returned $return_value\n";
}

I'm running NT4 Server/PHP4.3.2.2/IIS4.  This bit of code opened up 54 php.exe/cmd.exe (that's 54 of each or 108 total) processes on my machine.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-27 10:30 UTC] jlondon at mail dot mcg dot edu
No change...still runs like mad and crashes IIS.  I can't even do a "net stop".  I'm running the CGI version if that makes any difference.  Also I have to refer to php as c:/php/php otherwise error-output.txt has the message "he name specified is not recognized as an internal or external command, operable program or batch file."
 [2003-02-27 10:34 UTC] wez@php.net
Please try using the following for the command string:

"C:\\php\\cli\\php.exe"


 [2003-02-27 11:31 UTC] jlondon at mail dot mcg dot edu
Ok...that sort of worked.  No more hangs and no more spawned processes, but nothing is output to the screen.  The only thing I get is "command returned 128" but no hello world.  Also what is the difference between php.exe at the root of the dir and php.exe in the cli dir?  Why would one work and the other not?  Should I be using the one in the cli dir as my script processor?  Thanks a lot for you help.
 [2003-02-27 12:13 UTC] wez@php.net
Consult C:/temp/error-output.txt to see what went wrong with the child process.

The reason that the CGI did not work is that the CGI does not accept a script from stdin any longer.  (Whether this is intentional or not is still being discussed).

You should use the CGI version of PHP for handling CGI requests from the web server, but use the CLI when running scripts from the command line, or from your code, or whenever it is not running in a correctly prepared CGI environment.

I'd appreciate seeing that error-output.txt file so we can get a better idea of the problem.
 [2003-02-27 14:35 UTC] jlondon at mail dot mcg dot edu
The error-output.txt file was empty.  I thought maybe it was empty from a previous attempt so I deleted it and tried again and it came back empty again.  What does a return code of 128 mean?
 [2003-02-27 15:45 UTC] jlondon at mail dot mcg dot edu
Ok...looks like it works now.  I copied php4ts.dll to my system 32 directory and...duh...it works now.  Who knows why I didnt' copy it there when I did an install but it works now and that's all that matters.  Thanks for all your help.
 [2003-02-27 15:45 UTC] iliaa@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Bug result of old php libs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 13:01:29 2024 UTC