From: Jurgen Van Ham <juvanham.tc@gmail.com>
Date: Fri, 10 Feb 2017 06:55:23 +0000 (+0100)
Subject: procd: add cancel_timeout on rc scripts when a runtime_timeout is specified
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5f9124103410c178d816bb5229fba7dd2286a49b;p=oweals%2Fprocd.git

procd: add cancel_timeout on rc scripts when a runtime_timeout is specified

Enable procd to restrict the execution time of a rc scripts during shutdown, even
when a script ignores the SIGTERM signal by insisting after 10s with a SIGKILL.

Signed-off-by: Jurgen Van Ham <juvanham.tc@gmail.com>
---

diff --git a/rcS.c b/rcS.c
index 1e38d39..0208a75 100644
--- a/rcS.c
+++ b/rcS.c
@@ -121,8 +121,10 @@ static void add_initd(struct runqueue *q, char *file, char *param)
 	}
 	s->proc.task.type = &initd_type;
 	s->proc.task.complete = q_initd_complete;
-	if (!strcmp(param, "stop") || !strcmp(param, "shutdown"))
+	if (!strcmp(param, "stop") || !strcmp(param, "shutdown")) {
 		s->proc.task.run_timeout = 15000;
+		s->proc.task.cancel_timeout = 10000;
+	}
 	s->param = p;
 	s->file = f;
 	strcpy(s->param, param);