Hello everybody.
I'm very new to Qt platform. I'm using Qt 4.
I have to write a program to start more QProcesses, each one to run a different Sat solver on the same istance of sat problem.
So, when one is finished (I can't know which before) I want to take the result and kill all the other running QProcesses, because I have to solve more sat istances in an iterative algorithm.
I start QProcesses in the method run() of a class inheriting QThread (so the GUI application won't freeze) and exactly inside a for loop. I want the method run() to wait for a QProcess finished and then kill all the other in such a way to go on in the next iteraction.
The problem is that I have to wait for one QProcess finished but I can't use waitForFinished() method because it will wait for the corresponding QProcess to be finished, but I don't know which sat solver will finish as the first.
In the method run() of the class inheriting QThread, I have
connect(zchaff, SIGNAL(finished(int)), this, SLOT(killAll(void)));
connect(haifasat, SIGNAL(finished(int)), this, SLOT(killAll(void)));
for (int i = 0 ; i < list.size() ; i++){
zchaff->start("./zchaff.sh " + filename);
haifasat->start("./haifasat.sh " + filename );
if (!zchaff->waitForStarted()) return;
if (!haifasat->waitForStarted()) return;
// Here I don't know how to wait for one QProcess to be finished and kill the other
// Then I take the result of the one who's finished
}
zchaff = new QProcess;
haifasat = new QProcess;
connect(zchaff, SIGNAL(finished(int)), this, SLOT(killAll(void)));
connect(haifasat, SIGNAL(finished(int)), this, SLOT(killAll(void)));
for (int i = 0 ; i < list.size() ; i++){
zchaff->start("./zchaff.sh " + filename);
haifasat->start("./haifasat.sh " + filename );
if (!zchaff->waitForStarted()) return;
if (!haifasat->waitForStarted()) return;
// Here I don't know how to wait for one QProcess to be finished and kill the other
// Then I take the result of the one who's finished
}
To copy to clipboard, switch view to plain text mode
To be clear, In the QProcess I don't call exactly the sat solver executables but shell scripts, because I need to process the output with awk (I don't think it's a problem).
The slot killAll() of the same class is
void Thread::killAll(){
zchaff->kill();
haifasat->kill();
}
void Thread::killAll(){
zchaff->kill();
haifasat->kill();
}
To copy to clipboard, switch view to plain text mode
Summarizing, I ask you for a way to wait for a not-pre-determined QProcess termination and a coherent way to kill all the other process alive.
I thank you all in advance for your patience and your help!
Please help me, I'm very desperate!!!
Bookmarks