summary refs log tree commit diff
path: root/kitd.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2023-10-10 17:16:53 -0400
committerJune McEnroe <june@causal.agency>2023-10-10 17:16:53 -0400
commit9d864e5526d39ef974557c9b406bc3ada03ed4c1 (patch)
tree115fef03a2dbd425e7da3b3e2feaa38beca14c04 /kitd.c
parentParse interval suffixes (diff)
downloadkitd-7e746c091a083d6ed48dce0d45c0e4fb5dd466d2.tar.gz
kitd-7e746c091a083d6ed48dce0d45c0e4fb5dd466d2.zip
Add maximum restart interval HEAD 1.0 main
Diffstat (limited to 'kitd.c')
-rw-r--r--kitd.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/kitd.c b/kitd.c
index d76cac1..261f9eb 100644
--- a/kitd.c
+++ b/kitd.c
@@ -107,10 +107,12 @@ int main(int argc, char *argv[]) {
 	const char *name = NULL;
 	struct timeval restart = { .tv_sec = 1 };
 	struct timeval cooloff = { .tv_sec = 15*M };
-	for (int opt; 0 < (opt = getopt(argc, argv, "c:dn:t:"));) {
+	struct timeval maximum = { .tv_sec = 1*H };
+	for (int opt; 0 < (opt = getopt(argc, argv, "c:dm:n:t:"));) {
 		switch (opt) {
 			break; case 'c': parse(&cooloff, optarg);
 			break; case 'd': daemonize = false;
+			break; case 'm': parse(&maximum, optarg);
 			break; case 'n': name = optarg;
 			break; case 't': parse(&restart, optarg);
 			break; default: return 1;
@@ -257,7 +259,11 @@ int main(int argc, char *argv[]) {
 			syslog(LOG_INFO, "restarting in %s", humanize(&interval));
 			struct itimerval timer = { .it_value = interval };
 			setitimer(ITIMER_REAL, &timer, NULL);
+
 			timeradd(&interval, &interval, &interval);
+			if (timercmp(&interval, &maximum, >)) {
+				interval = maximum;
+			}
 		}
 
 		if (signals[SIGINFO]) {