forking a program on Windows [the solution!]

From: Date: Mon, 07 Oct 2002 20:14:35 +0000
Subject: forking a program on Windows [the solution!]
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-2510@lists.php.net to get a copy of this message
Hi! I have asked several times this question and I have also seen some guys reporting problems with forking on Windows. Now here is the solution which at least works for me to start up a browser with a given URL. If you need to make the started application focused and the PHP-GTK app inaccessible as long as the started app is not closed, use this code: function startBrowser($url) { pclose(popen("c:\\progra~1\\intern~1\\iexplore.exe $url", 'w')); } If you would like to start that application as a separate process and make the PHP-GTK app to be fully functional regardless of what is done to the newly opened one use this code: function startBrowser($url) { $command = popen(getenv("comspec"), 'w'); fputs($command, "c:\\progra~1\\intern~1\\iexplore.exe $url\n"); pclose($command); } Beware that regadless of the method you choose from the two above, the commands will be printed out to the dos window, so start up the PHP-GTK app with: php.exe -f gtkapp.php > NUL redirecting the output to NUL [something like /dev/null :)]. Thanks for the initial tip to Alex <syg dot etudes at syg dot fr>. Goba

« previous php.gtk.general (#2510) next »