Embedded applications are built to work without supervision. This includes the ability to recover from errors. If an application crashes, it can be restarted automatically. But what should we do if an application hangs by entering an endless loop or due to a deadlock?
Hardware or software watchdogs are used to prevent such situations. Applications should periodically notify or feed them to indicate that they keep operating normally. If a watchdog is not fed within a specific time interval, it terminates an application or restarts the system.
Many different implementations of watchdogs exist, but their interfaces are essentially the same. They provide a function that applications can use to reset the watchdog timer.
In this recipe, we will learn how to create a simple software watchdog on top of POSIX signals subsystems. The same technique can be used...