Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TerminateProcess() and windows messages.

TerminateProcess() and windows messages.

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 4 Posters 0 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Souldrift
    wrote on last edited by
    #1

    Hi there, I got the following problem. For an application that I have already up and running I wrote something like an observer program. The observer simply checks from time to time if the application is still alive and responding. If that is, for whatever reason, no the case, the observer kills the application process (TerminateProcess()) and starts another instance. Now that works quite well so far. Only when a windows error report or such something pops up in the trail of an application crash, the observer is unable to kill the application. So the whole mechanism breaks down. My question is, is there a possibility to kill an application nonetheless? Or to find out what is blocking the killing and to kill that one first then? I could get all the possible process names of the processes that might show up, but that will always leave a hole in the system. Any ideas on that? Souldrift

    D C _ 3 Replies Last reply
    0
    • S Souldrift

      Hi there, I got the following problem. For an application that I have already up and running I wrote something like an observer program. The observer simply checks from time to time if the application is still alive and responding. If that is, for whatever reason, no the case, the observer kills the application process (TerminateProcess()) and starts another instance. Now that works quite well so far. Only when a windows error report or such something pops up in the trail of an application crash, the observer is unable to kill the application. So the whole mechanism breaks down. My question is, is there a possibility to kill an application nonetheless? Or to find out what is blocking the killing and to kill that one first then? I could get all the possible process names of the processes that might show up, but that will always leave a hole in the system. Any ideas on that? Souldrift

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Souldrift wrote:

      My question is, is there a possibility to kill an application nonetheless?

      I would have thought TerminateProcess() to be the right choice as it is used to unconditionally cause a process to exit.

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      1 Reply Last reply
      0
      • S Souldrift

        Hi there, I got the following problem. For an application that I have already up and running I wrote something like an observer program. The observer simply checks from time to time if the application is still alive and responding. If that is, for whatever reason, no the case, the observer kills the application process (TerminateProcess()) and starts another instance. Now that works quite well so far. Only when a windows error report or such something pops up in the trail of an application crash, the observer is unable to kill the application. So the whole mechanism breaks down. My question is, is there a possibility to kill an application nonetheless? Or to find out what is blocking the killing and to kill that one first then? I could get all the possible process names of the processes that might show up, but that will always leave a hole in the system. Any ideas on that? Souldrift

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        First and foremost: never use TerminateProcess to terminate your application, there should be a better method. If you nonetheless want, at extreme stage, to kill unconditionally the application then use TerminateProcess (rules are there to be broken... :rolleyes: ): as suggested by David, there's no worst hammer than such a function (AFAIK). :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        1 Reply Last reply
        0
        • S Souldrift

          Hi there, I got the following problem. For an application that I have already up and running I wrote something like an observer program. The observer simply checks from time to time if the application is still alive and responding. If that is, for whatever reason, no the case, the observer kills the application process (TerminateProcess()) and starts another instance. Now that works quite well so far. Only when a windows error report or such something pops up in the trail of an application crash, the observer is unable to kill the application. So the whole mechanism breaks down. My question is, is there a possibility to kill an application nonetheless? Or to find out what is blocking the killing and to kill that one first then? I could get all the possible process names of the processes that might show up, but that will always leave a hole in the system. Any ideas on that? Souldrift

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          Check the return value of TerminateProcess() and get the error code, if any, using GetLastError(). Is the application and observer running in different user contexts? If so GetLastError should return Access Denied(5).

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups