Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to detect the appcrash (QProcess)
QtWS25 Last Chance

How to detect the appcrash (QProcess)

Scheduled Pinned Locked Moved General and Desktop
9 Posts 5 Posters 5.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    momondo
    wrote on 21 Oct 2013, 07:51 last edited by
    #1

    Hi everyone,
    as the title says how can I detect an appcrash in windows (the one where the user has to choose 2 options: check solution & close the program, close the program).

    I am actually making a scheduler program which using an extern application (*.exe), which is not programmed by me and there is no way to debug it. The scheduler program is using an user specified number of QProcess to concurrently execute the tasks and I also implement a synchronization there.
    This extern application crash sometimes, which cause the schedule to wait for user input (choose these 2 options: check solution & close the program, close the program). I usually start the schedule over night and expecting the end result to be available on the morning, but this appcrash made the schedule to be stuck :(

    PS: The crashes is actually can be ignored since from 1000 tasks it will occur 5 times only, which does not reallly alter the end result significantly.

    So anyone know the solution for detecting the appcrash?

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jeroentjehome
      wrote on 21 Oct 2013, 09:37 last edited by
      #2

      QProcess has multiple signals to do that.
      Catch this signal and you should be able to detect a crash of the external app:
      @
      void QProcess::error(QProcess::ProcessError error) [signal]
      @
      The ProcessError has a crashed enum value etc.
      Greetz

      Greetz, Jeroen

      1 Reply Last reply
      0
      • M Offline
        M Offline
        momondo
        wrote on 21 Oct 2013, 11:13 last edited by
        #3

        Hi Jeroentje,

        thank you very much for your reply.

        I tried it but it still display the crash window, which holds the execution of the next tasks.

        I forgot to mention my intention:
        What I want is to ignore the error and continue using the process for the next task. Because I want to leave the program running over night (unattended) and expect the end-result on the morning.

        PS: By ignore I mean kill the process without the user has to take some action (i.e. choosing one of the option).

        Any suggestion?

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 21 Oct 2013, 11:23 last edited by
          #4

          Hi,
          If you want to suppress the crash dialog.
          May be "this":http://blogs.msdn.com/b/alejacma/archive/2011/02/18/how-to-disable-the-pop-up-that-windows-shows-when-an-app-crashes.aspx would help you.

          157

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MuldeR
            wrote on 21 Oct 2013, 11:39 last edited by
            #5

            [quote author="p3c0" date="1382354619"]Hi,
            If you want to suppress the crash dialog.
            May be "this":http://blogs.msdn.com/b/alejacma/archive/2011/02/18/how-to-disable-the-pop-up-that-windows-shows-when-an-app-crashes.aspx would help you.[/quote]

            No need for registry hacks, just use SetErrorMode(), probably with SEM_FAILCRITICALERRORS and SEM_NOGPFAULTERRORBOX() flags. You should call this early in your process.

            My OpenSource software at: http://muldersoft.com/

            Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

            Go visit the coop: http://youtu.be/Jay...

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p3c0
              Moderators
              wrote on 21 Oct 2013, 11:59 last edited by
              #6

              Ok. This seems to be a more cleaner example. But will it work for his external process? And also he says the external exe is not programmed by him.

              157

              1 Reply Last reply
              0
              • M Offline
                M Offline
                MuldeR
                wrote on 21 Oct 2013, 12:10 last edited by
                #7

                If the external EXE is not programmed by him, he cannot do it that way :-(

                But he can still do it via Job control!

                • Create job object via CreateJobObject()
                • Use SetInformationJobObject() with parameter JobObjectBasicLimitInformation
                • In the JOBOBJECT_BASIC_LIMIT_INFORMATION struct, set JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION flag
                • Assign new process to the job via AssignProcessToJobObject()

                __

                Important notice:

                There's a longstanding bug/limitation in QProcess that prevents Job Control from working properly. AssignProcessToJobObject() will always fail!

                You need to include the following fix when compiling Qt:
                http://pastie.org/private/krtzp6jzilju6ejv8ppwa

                My OpenSource software at: http://muldersoft.com/

                Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

                Go visit the coop: http://youtu.be/Jay...

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  momondo
                  wrote on 21 Oct 2013, 12:18 last edited by
                  #8

                  Hi,

                  yea that is true the exes are not programmed by me.

                  MuldeR: so I can not do your solution but thank you for introduing the functions. Never knew about this before.

                  p3c0 : thank you this is just what I need :D

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    NicuPopescu
                    wrote on 21 Oct 2013, 13:17 last edited by
                    #9

                    Hi,

                    bq. I forgot to mention my intention:
                    What I want is to ignore the error and continue using the process for the next task. Because I want to leave the program running over night (unattended) and expect the end-result on the morning.

                    by which method have you started the process? I have not seen or missed that :)

                    I did simple tests with a simulated app's crash and I think what you need to achieve, starting many processes avoiding your app hanging on if one of them crashes and sync finshed() signaling to get a task's result, depends on the method used to start the process: for me it worked with start() but each QProcess must be a different object (not same object starting the same external exe!) ... in this way even for a crashed process you can catch the finished() signal after the error dialog's closing ...

                    hope it will work for you!

                    Cheers!

                    1 Reply Last reply
                    0

                    5/9

                    21 Oct 2013, 11:39

                    • Login

                    • Login or register to search.
                    5 out of 9
                    • First post
                      5/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved