aboutsummaryrefslogtreecommitdiff
path: root/lib/src
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 /lib/src
parent09115f9a97b820c69eb29d3621a4e65dac3dbfc5 (diff)
Add service respawn limit
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/rdsvc.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/src/rdsvc.c b/lib/src/rdsvc.c
index 972f7e4..54c6d24 100644
--- a/lib/src/rdsvc.c
+++ b/lib/src/rdsvc.c
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
+#include <ctype.h>
#include "service.h"
#include "util.h"
@@ -132,6 +133,32 @@ static int svc_target(service_t *svc, char *arg,
return 0;
}
+static int svc_rspwn_limit(service_t *svc, char *arg,
+ const char *filename, size_t lineno)
+{
+ const char *ptr;
+
+ svc->rspwn_limit = 0;
+
+ if (!isdigit(*arg))
+ goto fail;
+
+ for (ptr = arg; isdigit(*ptr); ++ptr)
+ svc->rspwn_limit = svc->rspwn_limit * 10 + (*ptr - '0');
+
+ if (*ptr != '\0')
+ goto fail;
+
+ free(arg);
+ return 0;
+fail:
+ fprintf(stderr,
+ "%s: %zu: expected numeric argument for respawn limit\n",
+ filename, lineno);
+ free(arg);
+ return -1;
+}
+
static const struct {
const char *key;
@@ -147,6 +174,7 @@ static const struct {
{ "tty", svc_tty },
{ "before", svc_before },
{ "after", svc_after },
+ { "respawn_limit", svc_rspwn_limit },
};