tags:

views:

28

answers:

2

I know Windows close kernel handles when an application crashes, but if I want to wait on this event, can I be sure it will happen in milisec or it might take a while? I would like to trigger a new function the moment one application is crashed and I'm checking if this handle is NULL but it seems like I can't get a NULL value in this case.

+2  A: 

How long it will take may vary depending upon many factors including implementation, type of crash, etc. It might take awhile.

If you want to know when a process has crashed, you should set up a "watchdog" thread or process that waits on the application's Process Handle, using a function such as WaitForSingleObject. When the process dies, the event will be signaled and you can act accordingly.

Justin Ethier
A: 

Windows does not close handles when an application "crashes" - it closes them when the process terminates, no matter how the process terminates. By the time this happens the variables don't exist any more because the user mode address space has been shut down.

What are you trying to do?

Stewart
I'm trying to keep a functionality working all the time by useing two different processes, the problem is that only one process can do it in a given moment. I want to make sure that if one process crashed the other will take the permission and activate the functionality. How can I set a "watch dog" for that - how can I trigger an event I don't know when it should be popped?
Netta D
As Justin Ethier says, get a handle to the other process and wait on that. As soon as the other process exits, the handle will be signalled and that will be your cue to take over.
Stewart