Issue using WshShell->Exec with fastcgi
Results 1 to 9 of 9

Thread: Issue using WshShell->Exec with fastcgi

  1. #1
    Junior Member
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    2

    Issue using WshShell->Exec with fastcgi

    I'm having an issue I can't quite figure out with php and fastcgi. I have a need to run a process in the background, but I'd like to grab the PID so I can monitor its progress and report to the user when it's finished via an AJAX request.

    My only issue is that FastCGI seems to crash when I launch a process with the WshShell->Exec method, but not when I use the WshShell->Run method. It actually works fine, returns the correct pid, and runs the process in the background...but once script execution is done, the fastcgi worker process crashes. If I refresh the page several times and fastcgi hits its limit on child processes, I get a 500 internal error stating that the worker process crashed, until a new worker process is spawned a second later.

    The following also shows up in the error log when the worker process crashes:Faulting application php-cgi.exe, version 5.3.6.0, faulting module unknown, version 0.0.0.0, fault address 0x572529b0.

    Any idea why Exec would crash the process but Run wouldn't?

    Works:
    Code:
    <?
    	$WshShell = new COM("WScript.Shell");
    	$oExec = $WshShell->Run("ping 127.0.0.1",0,false);
    ?>
    Crashes:
    Code:
    <?
    	$WshShell = new COM("WScript.Shell");
    	$oExec = $WshShell->Exec("ping 127.0.0.1");
    ?>

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,428
    If you can write PHP code that causes the PHP binary to fault, I would say you might want to consider filing a bug report.

  3. #3
    Senior Member
    Join Date
    Apr 2003
    Posts
    266
    One possible reason is that the exec method returns an object while the run method returns a success boolean. I don't know if that matters in php code, but it would in vb code, you'd need to use the set keyword with the return variable from the exec method, but not the run method.

    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
    ======
    Doug G
    ======

  4. #4
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,428
    I was unable to reproduce the crash on PHP 5.3.10 via the CLI.

    My PHP version:
    Code:
    C:\php>php -v
    PHP 5.3.10 (cli) (built: Feb  2 2012 20:27:51)
    Copyright (c) 1997-2012 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    My test code:
    PHP Code:
    <?php
        $WshShell 
    = new COM("WScript.Shell");
        
    $oExec $WshShell->Exec("ping 127.0.0.1");
        
    var_dump($oExec->status);
    ?>
    The output:
    Code:
    int(0)

  5. #5
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    1,782
    Interesting...

    PHP Code:
    <?php 
        $WshShell 
    = new COM("WScript.Shell"); 
        
    $oExec $WshShell->Exec("ping 127.0.0.1"); 
        
    var_dump($oExec->status); 
    ?>
    Outputs int(0)

    However
    PHP Code:
    <?php 
        $WshShell 
    = new COM("WScript.Shell"); 
        
    $oExec $WshShell->Exec("ping 127.0.0.1"); 
        
    var_dump($oExec); 
    ?>
    Crashes Apache HTTP... So maybe its possible you are trying to use the variable $oExec improperly?
    Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
    I'd rather be a comma, then a full stop.
    User Authentication in PHP with MySQLi - Don't forget to mark threads resolved - MySQL(i) warning

  6. #6
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,885
    I can replicate this (PHP 5.4.0 TS/ Apache 2.2.21; VC9 builds).

    The crash definitely happens at the var_dump() stage, and it doesn't really seem to matter what the scripting host did (other commands can be substituted for the ping).

    I agree: file this as a bug.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  7. #7
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,428
    Can either of you two replicate the same crash via the CLI? I'm getting:
    Code:
    object(variant)#2 (0) {
    }
    now on PHP 5.3.3 CLI and (Apache/2.2.14 (Win32) PHP/5.3.3, MSVC6 build). I'll try matching Weedpacket's installation in a bit.

  8. #8
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    1,782
    I can get that via CLI
    Apache 2.2.21 PHP 5.3.9 VC9 x64

    But I still get a crash from Apache HTTP Server when accessing via browser.

    Edit: For completeness this is all my script contains:
    PHP Code:
    <?php
        $WshShell 
    = new COM("WScript.Shell");
        
    $oExec $WshShell->Exec("ping 127.0.0.1");
       
    var_dump($oExec);
    ?>
    Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
    I'd rather be a comma, then a full stop.
    User Authentication in PHP with MySQLi - Don't forget to mark threads resolved - MySQL(i) warning

  9. #9
    Junior Member
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    2
    Sorry guys/girls, I started working on something else and sortof forgot about this for a bit.

    It's always worked via CLI for me, which is why I was thinking it had something to do with fastcgi. When you're getting crashes from apache, do you have it configured for CGI/fastCGI? I was using IIS 6.

    I didn't see IIS actually crash, it was the fastcgi process that hung, and IIS would start a new one (...maybe that's what you're seeing at the var_dump stage?)

    I find it odd that it worked fine via CLI but through IIS/fastcgi, when it crashed, it showed up in the event log as php-cgi.exe...if it WERE a php issue, I'd think it would crash via CLI too, if it were fastcgi or IIS I'd think it would show the binary for those in the event log instead.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •