1

I need to make sure that a chosen process is not hanged. I thought I'd program this process to write to some /proc file that will be periodically monitored by some other process/module. If there is no change in the file for some time the application would be considered hanged. Just as a watchdog in uC.

However I don't know if this is the best approach. As I'm not really much into deep Linux engineering I thought it is better to ask which way is the easiest before starting to learn writing modules, /proc filesystem, etc. Ha!

I've found some information on Monit (https://mmonit.com/monit/). Maybe this would be better?

What would you recommend to be the best way to implement the "watchdog" functionality here?

Thanks a lot!

Paweł

Felipe Lavratti
  • 2,887
  • 16
  • 34
Paweł J
  • 33
  • 1
  • 10
  • Which init system are using? – Frank Meerkötter Dec 07 '16 at 17:17
  • I use BusyBox init, that does not support runlevels. I got no /etc/rc* entries, but run init.d scripts. This is to answer your question, @FrankMeerkötter, but Felipe Lavratti helped me to already find a solution. Thanks! – Paweł J Dec 09 '16 at 10:12

1 Answers1

1

An OS independent solution is to create a watchdog thread that runs periodically and supports one or more software watchdogs, which are simply implemented as status bits or bytes. The process in question is responsible for patting the watchdog (clearing the status). The watchdog thread is a loop which checks the status. If it has been cleared, it sets it. If it has not been cleared, it alarms. You can adjust the timing so that the status is not checked each time through the loop.

This solution is quite flexible. You can also tie it into the hardware watchdog, patting the hw watchdog only if all software watchdogs have been patted.

Bruce
  • 2,230
  • 18
  • 34