The accompanying code takes care of another application (call it "myApp") that should always be running.
It wakes up every X times, and checks the following:
- Is myApp running? If not, it turns it on.
- Is myApp hanging? (This is decided by myApp not consuming any CPU usage during the last X times and since the previous check.) If yes, kills it and restarts it.
- Is myApp already running for Y time? If yes, kills it and restarts it.
The program keeps a log file of its actions (checking, restarting, killing). It also copies the log file of myApp (if any) to another location (same name, plus date and time concatenated), so that the information in it will not get lost.
This code was compiled under VC++ 6.0. It needs the following definitions: