1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-11-05 12:17:10 +01:00
init/initd/runsvc.c
David Oberhollenzer 9f9807d4d3 cleanup: initd: simplify and merge linux specific code into main.c
Targetting anything else than Linux isn't really relevant. All
other systems ($BSD and other Unices) are a closed ecosystem
where kernel & userspace are developed together. They don't need
something like a third party init system, so compatibillity can
be largely ignored.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-03-31 13:09:04 +02:00

38 lines
584 B
C

/* SPDX-License-Identifier: ISC */
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "init.h"
pid_t runsvc(service_t *svc)
{
char *argv[4], *envp[1];
sigset_t mask;
pid_t pid;
argv[0] = (char *)RUNSVCBIN;
argv[1] = (char *)SVCDIR;
argv[2] = svc->fname;
argv[3] = NULL;
envp[0] = NULL;
pid = fork();
if (pid == -1)
perror("fork");
if (pid == 0) {
sigemptyset(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL);
execve(argv[0], argv, envp);
perror(argv[0]);
exit(EXIT_FAILURE);
}
return pid;
}