Php fork() on windows

  •  After making some php program, or script for that matter i'm trying to fork a process so the script continues, on a win32 platform:




    function servername() {
        $servername = "EMPTY";
        while ($servername != "") {
            fwrite(STDOUT, "Server: ");
            $servername = trim(fgets(STDIN));
            if ($servername === "") {
            $connect_check = fsockopen($servername, 80, $errno, $errstr, 1);
            if ($errstr != "") {
                echo "\nCan't connect to http://".$servername."\n";           
            else     {

    function start_ie($servername) {
        $iexplore = '"c:\program files\internet explorer\iexplore.exe" http://';


    Now I know that forking is not (default?) implemented in win32 php, anyone got a workaround for this?

     it is a cli program, run from the shell (cmd.exe)




  •  Uhhh I forgot to mention that i want the else, the start_ie function to fork

  • You just need a CLI program that will take a program to start and will fork off that program and return control to the script.  I don't know a lot about process control under Windows but surely there's some freeware prog out there to do this. 

  •  Try psexec - it's part of pstools from SysInternals (now Microsoft).  I don't remember the current url, but should redirect to the right page.


  •  psexec -d indeed does the trick!

      Thank you!

Log in to reply

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.