i have done my program mainApp that owns main() method and main() creates 5 threads, threads do some operations.. so on.
now im just wondering if my program crashes. So im gonna monitor my mainApp whether it is working or stopped. if stopped Im gonna restart/reboot the whole system.
mainApp and monitoring program have to run at the same time and monitor prog should check mainApp’s status.
any suggestions pls.
PS: im om linux kernel 2.6.29.
Unless you want a general purpose monitor, your program can monitor itself.
When the program first starts, the program itself is the monitor. Since the program is just starting, there is no “mainApp” running, so it forks itself off. The child process assumes the role of the “mainApp”. The monitor now waits for the child process to die. When the child process dies, it checks the status, and ff a restart is decided, then it forks again.