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:
<?php
servername();
function servername() {
$servername = "EMPTY";
while ($servername != "") {
fwrite(STDOUT, "Server: ");
$servername = trim(fgets(STDIN));
if ($servername === "") {
die();
};
$connect_check = fsockopen($servername, 80, $errno, $errstr, 1);
if ($errstr != "") {
echo "\nCan't connect to http://".$servername."\n";
}
else {
start_ie($servername);
};
};
};
function start_ie($servername) {
$iexplore = '"c:\program files\internet explorer\iexplore.exe" http://';
$cmd=$iexplore.$servername;
exec($cmd);
};
?>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 sysinternals.com should redirect to the right page.
-
psexec -d indeed does the trick!
Thank you!