Results 1 to 4 of 4

Thread: Detect First QProcess finished in a group and kill other

  1. #1
    Join Date
    Jul 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Detect First QProcess finished in a group and kill other

    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

    Qt Code:
    1. zchaff = new QProcess;
    2. haifasat = new QProcess;
    3.  
    4. connect(zchaff, SIGNAL(finished(int)), this, SLOT(killAll(void)));
    5. connect(haifasat, SIGNAL(finished(int)), this, SLOT(killAll(void)));
    6.  
    7. for (int i = 0 ; i < list.size() ; i++){
    8. zchaff->start("./zchaff.sh " + filename);
    9. haifasat->start("./haifasat.sh " + filename );
    10.  
    11. if (!zchaff->waitForStarted()) return;
    12. if (!haifasat->waitForStarted()) return;
    13. // Here I don't know how to wait for one QProcess to be finished and kill the other
    14.  
    15. // Then I take the result of the one who's finished
    16. }
    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

    Qt Code:
    1. void Thread::killAll(){
    2. zchaff->kill();
    3. haifasat->kill();
    4. }
    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!!!
    Last edited by Davidaino; 11th July 2008 at 02:26.

  2. #2
    Join Date
    Jul 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Detect First QProcess finished in a group and kill other

    Just to be shorter.
    How can I wait for one QProcess (having more than one running) to be finished without knowing which will be finished as the first?

    Please answer me!!! I NEED HELP!!!

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Detect First QProcess finished in a group and kill other

    Don't shout

    Rely on signals - QProcess::finished will notify you that a particular process has finished. You can then terminate the remaining ones.

  4. #4
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Detect First QProcess finished in a group and kill other

    I think you can kill your process by knowing its process id........
    use Q_PID QProcess:id () const .............
    It will help you ..........

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.