Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A server program is on an infinite loop. How to check for it?

A server program is on an infinite loop. How to check for it?

My solution:

use GDB to check the values of condition variables that control the loop.

It is ok for small program.

how to do that for large program ?

If the program is not running in GDB, how to detect the endless loop ?

thanks

like image 708
user1002288 Avatar asked Oct 28 '25 15:10

user1002288


1 Answers

You could use some form of a watchdog timer. Have the program output a character or touch a file periodically, so if it gets stuck in a loop, a separate process can detect that the watchdog has not been updated and kill/reset the process.

A lot of microcontrollers have this built into the hardware, and they will automatically reset if you don't reset the timer. It's very handy :)

like image 65
Chriszuma Avatar answered Oct 31 '25 06:10

Chriszuma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!