mirror of
https://github.com/pygos/init.git
synced 2024-12-22 15:20:49 +01:00
initd: Hand out unique IDs to services
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
parent
d16d260181
commit
c16735414b
3 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue