A software watchdog, killing the current process after the given number of seconds.
On Posix systems (Linux, MacOS), this is implemented with a call to alarm() that will emit the SIGALRM signal after the provided number of seconds. A signal handler is declared that throws an exeption when the SIGALRM signal is caught, so a stack trace can be printed before exiting.
On Microsoft Windows, this is implemented as a QueueTimer with a processing function called when the timer expires. This function prints an error message and exits with EXIT_FAILURE.
Please note that in the current implementation, it is not possible to reset the watchdog.
#include <Timer.h>
Public Member Functions | |
WatchDog (const unsigned int &seconds) | |
Create the watchdog. More... | |
mio::WatchDog::WatchDog | ( | const unsigned int & | seconds | ) |
Create the watchdog.
seconds | number of seconds before killing the process |