aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2019-03-28 13:44:28 +0100
committerDavid Oberhollenzer <goliath@infraroot.at>2019-03-28 13:45:33 +0100
commitc16735414ba63cb593881cd32e46dc086f003181 (patch)
tree5dc8e79e8d2dd82e91c89ec0c028e11858a71131
parentd16d26018126d381954110e8cdb788650eb41d9e (diff)
initd: Hand out unique IDs to services
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
-rw-r--r--initd/supervisor.c4
-rw-r--r--lib/include/service.h1
-rw-r--r--lib/init/rdsvc.c1
3 files changed, 6 insertions, 0 deletions
diff --git a/initd/supervisor.c b/initd/supervisor.c
index 4f7ddc9..871618a 100644
--- a/initd/supervisor.c
+++ b/initd/supervisor.c
@@ -3,6 +3,7 @@
static service_list_t cfg;
+static int service_id = 1;
static int target = -1;
static service_t *running = NULL;
static service_t *terminated = NULL;
@@ -14,6 +15,9 @@ static bool waiting = false;
static int start_service(service_t *svc)
{
+ if (svc->id < 1)
+ svc->id = service_id++;
+
svc->pid = runsvc(svc);
if (svc->pid == -1) {
print_status(svc->desc, STATUS_FAIL, false);
diff --git a/lib/include/service.h b/lib/include/service.h
index 85b82c5..1ff5204 100644
--- a/lib/include/service.h
+++ b/lib/include/service.h
@@ -68,6 +68,7 @@ typedef struct service_t {
pid_t pid;
int status; /* process exit status */
+ int id; /* service ID used by initd */
char name[]; /* canonical service name */
} service_t;
diff --git a/lib/init/rdsvc.c b/lib/init/rdsvc.c
index 7ce68e3..0e5bc99 100644
--- a/lib/init/rdsvc.c
+++ b/lib/init/rdsvc.c
@@ -261,6 +261,7 @@ service_t *rdsvc(int dirfd, const char *filename, int flags)
}
memcpy(svc->name, filename, nlen);
+ svc->id = -1;
if (rdcfg(svc, &rd, svc_params, ARRAY_SIZE(svc_params), flags))
goto fail;