« Previous Next »

Thread: unable to fork, the mystery...

Last post 10-06-2009 3:38 PM by pierrejoye. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 09-29-2009, 2:44 PM

    • jbreiding
    • Not Ranked
    • Joined on 06-24-2002, 10:25 AM
    • Posts 4

    unable to fork, the mystery...

    php 5.3 (x86 fastcgi)

    windows server 2k8 (x64)

     I have spent a good few days googling around and trying things so let me give you the current state.

    cmd.exe copied to php folder, all instances of cmd.exe, including syswow64, given read execute permissions to domain users, local users, iis_iusrs, network service in addition to the defaults

    from my users command prompt i can execute php c:\inetpub\wwwroot\forktest.php, as well the same with php-cgi -f c:\inetpub\wwwroot\forktest.php

     system() is giving  a return_val of -1

    in procmon.exe i can actually see the create call succeed. the application being executed has also been given the same permissions as cmd.exe, however it is not in the php folder but the full path has been given.

     my application pool, default setup, runs under network service.

    any thoughts and suggestions will be appreciated!

  • 09-29-2009, 3:03 PM In reply to

    Re: unable to fork, the mystery...

    Hi,

    Let me summarize what my understanding of the problem is:

    • Your PHP with FastCGI is configured properly. I mean a simple PHP page works fine and so I am assuming that configuration is not a problem.
    • From the PHP code you are trying to run some executable by perpending cmd.exe to it (example, if the application you are trying to run is 'dir' the command you want to run is "cmd.exe dir /s" using PHP sysytem function)
    • I didn't understand why you copied cmd.exe to PHP install folder and changed all it's permission.
    • While executing your test code 'forktest.php', system command fails both for PHP CLI as well as PHP CGI. Right? Can you let us know what is the actual code you are trying to run (please be short and precise). If the application you are trying to run is an internal application try replacing it with "dir", "findstr" etc. and see if the problems still exists and paste  the small code here.
    • Is PROCMON.EXE showing the full path and is it not the same as one pointing to PHP install folder. Example please. I mean clearly state, what path to application you expect and what did you get? See executables are find as per PATH environment variable. And the first match is returned. maybe what you want is not the first match in the PATH environment variable.

    Thanks,

    Don.

  • 09-29-2009, 3:17 PM In reply to

    • jbreiding
    • Not Ranked
    • Joined on 06-24-2002, 10:25 AM
    • Posts 4

    Re: unable to fork, the mystery...

    yes simple php works just fine, even the full mediawiki application works fine. i copied cmd.exe to my php folder as i had seen this as one resolution, and given how php-cgi.exe will attempt to load an application from its own folder before attempting through the system path, it made sense.

     no, executing from an open command window php.exe c:\inetpub\wwwroot\forktest.php, or php-cgi.exe -f c:\inetpub\wwwroot\forktest.php does work. so the problem doesnt reside in php itself. its some sort of permissions issue, i believe.

    here is a snippet that is failing from forktest.php

    <?php
    $result = 0;
    $resultstr = system('echo %PATH%', $result);
    echo "return value is $result \n";
    echo "output string is $resultstr \n";
    ?>

     output:

    Warning: system() [function.system]: Unable to fork [echo %PATH%] in C:\inetpub\wwwroot\forktest.php on line 25
    return value is -1 output string is

     i went ahead and deleted the cmd.exe in my php folder and in procmon i am seeing exactly what should be happening, c:\windows\syswow64\cmd.exe.

     it seems my problem is actually executing cmd.exe, not the application i am attempting to execute.

  • 09-29-2009, 4:17 PM In reply to

    Re: unable to fork, the mystery...

    Do you have fastcgi.impersonate=1 set in your PHP.INI file? It works fine for me here. And yes please try moving back to PHP 5.2.11 and see if it works. This can be a bug in PHP 5.3 as well.

    Thanks,

    Don.

  • 09-29-2009, 4:43 PM In reply to

    • jbreiding
    • Not Ranked
    • Joined on 06-24-2002, 10:25 AM
    • Posts 4

    Re: unable to fork, the mystery...

    impersonate was already set, i moved back to 5.2.11 and the commands are now working. guess i should file a bug.

     thanks.

  • 09-29-2009, 4:57 PM In reply to

    • jbreiding
    • Not Ranked
    • Joined on 06-24-2002, 10:25 AM
    • Posts 4

    Re: unable to fork, the mystery...

  • 10-06-2009, 3:38 PM In reply to

    Re: unable to fork, the mystery...

    There was a bug introduced in last 5.3.0 RC. It is now fixed in SVN, as I told you in the bug itself, please try a snapshot. You can fetch one from http://windows.php.net

    --
    Pierre

    http://blog.thepimp.net | http://windows.php.net
Page 1 of 1 (7 items)
Microsoft Communities