QProcess and shell : Destroyed while process is still running

user2007861 picture user2007861 · Jan 24, 2013 · Viewed 17.5k times · Source

I want to launch a shell script with Qt.

QProcess process;
process.start(commandLine, QStringList() << confFile);
process.waitForFinished();

if(process.exitCode()!=0)
{
    qDebug () << " Error " << process.exitCode() << process.readAllStrandardError();
}
else
{
    qDebug () << " Ok " << process.readAllStrandardOutput() << process.readAllStrandardError();
}

The result is :

Ok : Result.... " "" QProcess : Destroyed while process is still running.

This message does not appear every time.

What is the problem?

Answer

sashoalm picture sashoalm · Jan 24, 2013

process.waitForFinished(); is hitting the default 30 seconds timeout. Use process.waitForFinished(-1); instead. This will make sure you wait for however long it takes for the process to finish, without any timeout.