• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 491
  • Last Modified:

How to receive a message that an application has crashed?


I am working on an application that changes some settings in the disk manager after it launches. It undoes all those changes when it is closed properly.

However when the application crashes because of some reason, it can't undo the changes it did. I am planning to write some sort of a service, which waits for a notification that the application has crashed, and undoes all the changes done by the application.

Is there anyway for one application or a process to be informed when another application crashes? I mean is there any sort of event or message that windows throws for this case?
2 Solutions
you might want to look at Servers Alive application.  It can carry out actions off the back of a failure.
Write it as a service and have your service installer specify the Recovery option of running another application on the first failure.
One simple option might be to wrap your application in another application.
For example, create a class called, for example, MainApplication. Give it a method called Run that takes no parameters and returns no values, eg:
void MainApplication::Run()

transfer all the functionality of your existing program to this class, and all the code from your main() function to the Run() method.
Now create a wrapper program, I will call it TestHarness.
In the main function create an instance of your class inside a try-catch block and call the run method.
If it crashes it should raise an exception which your harness program can capture. You will then know immediately if iit has crashed.
You can then perform whatever cleanup stuff you need to.

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now