Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

qt - QProcess and shell : Destroyed while process is still running

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...