PDA

View Full Version : QProcess::startDetached on windows, some processes exit immediately



sandor
19th August 2012, 17:00
I have server what starts clients using the QProcess::startDetached. Those clients connect to the server using TCP and stay working (processing data from the server) as long the server runs; they terminate when the socket connection is lost.

But... there is a problem with startDetached I could not solve so far. It works fine for ".exe" files compiled in Visual Studio. However, I have some clients written in php. The php files just blink in a window and those are gone. Log clearly shows that those are started but somehow they vanish to void. If I start those scripts manually from a cmd.exe "shell" then those all work just fine.

I tried:
QProcess::startDetached("php xyz.php -param1 1 -param2 2");
QProcess::startDetached("C:\Program Files (x86)\PHP\php.exe xyz.php -param1 1 -param2 2");
QProcess::startDetached("cmd /C C:\Program Files (x86)\PHP\php.exe xyz.php -param1 1 -param2 2");
QProcess::startDetached("cmd /C \"C:\Program Files (x86)\PHP\php.exe xyz.php -param1 1 -param2 2\"");

In both four cases, startDetached returns true and I see a blink so a window is created for the php script but it disappears to quick to read. Hmm, any idea? Again, those scripts run fine if started from an already existing cmd.exe so there is some trick there; what might that be?

amleto
19th August 2012, 18:08
errr, so if you want the shell to stay open, why use /C ???