TerminateProcess() and windows messages.
-
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
-
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
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
-
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
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 useTerminateProcess
(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] -
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
Check the return value of
TerminateProcess()
and get the error code, if any, usingGetLastError()
. Is the application and observer running in different user contexts? If soGetLastError
should returnAccess Denied(5)
.«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++)