service: stop the restart counter of restart always from overflowing

The restart counter is a char, and with restart always nothing stops
it.  A service restarted more often than the counter ages wrapped it
after 127 restarts, 255 on Arm.  initctl status then showed a negative
count and the back-off fell back to two seconds.

Make the counter an int that stops at INT_MAX.  With restart always it
stops at 10, the default restart-max.  The back-off peaks at half of
that, and from 10 the counter ages back within the hour.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-19 20:39:41 +01:00
1 parent 4e1b0d4fbe
commit 644279cd72
3 files changed
+20 -7

No files matched your search

+1 -1
View File
@@ -179,7 +179,7 @@ typedef struct svc {
int restart_tmo; /* Time before restarting a crashing service */
unsigned char oncrash_action; /* Action to perform in crashed state. */
char respawn; /* ttys, or services with `respawn`, never increment restart_cnt */
const char restart_cnt; /* Incremented for each restart by service monitor. */
const int restart_cnt; /* Incremented for each restart by service monitor. */
union {
/* services we redirect stdout/stderr to syslog (not TTYs!) */