summaryrefslogtreecommitdiff
path: root/initd/main.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-26 00:34:00 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-03-26 00:40:28 +0200
commit160ef94e8b6aa580225555a9c38a99af2d4e27d2 (patch)
tree6a6b605265b1509de68b474774dfb7e13f203ab8 /initd/main.c
parent09115f9a97b820c69eb29d3621a4e65dac3dbfc5 (diff)
Add service respawn limit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'initd/main.c')
-rw-r--r--initd/main.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/initd/main.c b/initd/main.c
index efd3a30..9ce23c0 100644
--- a/initd/main.c
+++ b/initd/main.c
@@ -43,6 +43,16 @@ static void handle_exited(service_t *svc)
break;
}
+ if (svc->rspwn_limit > 0) {
+ svc->rspwn_limit -= 1;
+
+ if (svc->rspwn_limit == 0) {
+ print_status(svc->desc, STATUS_FAIL, false);
+ delsvc(svc);
+ break;
+ }
+ }
+
svc->pid = runlst(svc->exec, svc->num_exec, svc->ctty);
if (svc->pid == -1) {
print_status(svc->desc, STATUS_FAIL, false);