Results 1 to 2 of 2

Thread: How do I close a QProcess after a main app crash/terminate

  1. #1
    Join Date
    Oct 2009
    Posts
    22
    Thanks
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How do I close a QProcess after a main app crash/terminate

    Hi,

    What can I do about a QProcess that is still running after the main application has not closed down cleanly.

    For example if I start running my application in QtCreator and then hit 'Stop' to terminate the program the external process that I launched using QProcess is still running. Without using killall on the next run what are my options? It is imperative that I don't run multiple instances of this process.

    Thanks

    H

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How do I close a QProcess after a main app crash/terminate

    You could obtain the list of running processes and look for an existing instance of the child process. I do not know a readily available platform-independent wrapper to do so. Under Windows, you can use EnumProcesses() or the Tool Help library; under Linux, see the /proc filesystem; I do not remember how to do it under MacOS X.

    In any case this will never prevent anyone to run as many instances of the process as they wish after your program has tested that none was currently running.

Similar Threads

  1. Replies: 3
    Last Post: 4th December 2011, 22:29
  2. How to close two main windows at a time
    By soumya in forum Qt Programming
    Replies: 7
    Last Post: 4th February 2010, 16:12
  3. QProcess doesn't terminate
    By Bagstone in forum Qt Programming
    Replies: 4
    Last Post: 8th February 2008, 00:43
  4. How to close all windows that were created in main()?
    By Mister_Crac in forum Qt Programming
    Replies: 6
    Last Post: 13th November 2006, 10:57
  5. Replies: 4
    Last Post: 27th July 2006, 11:13

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.