2018-11-23 13:13:23 +01:00
|
|
|
/* SPDX-License-Identifier: ISC */
|
2018-04-22 01:02:27 +02:00
|
|
|
#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];
|
2020-03-31 13:09:04 +02:00
|
|
|
sigset_t mask;
|
2018-04-22 01:02:27 +02:00
|
|
|
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) {
|
2020-03-31 13:09:04 +02:00
|
|
|
sigemptyset(&mask);
|
|
|
|
sigprocmask(SIG_SETMASK, &mask, NULL);
|
|
|
|
|
2018-04-22 01:02:27 +02:00
|
|
|
execve(argv[0], argv, envp);
|
|
|
|
perror(argv[0]);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pid;
|
|
|
|
}
|