aboutsummaryrefslogtreecommitdiff
path: root/initd/runsvc.c
diff options
context:
space:
mode:
Diffstat (limited to 'initd/runsvc.c')
-rw-r--r--initd/runsvc.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/initd/runsvc.c b/initd/runsvc.c
index b30e8e3..144490b 100644
--- a/initd/runsvc.c
+++ b/initd/runsvc.c
@@ -132,13 +132,13 @@ static __attribute__((noreturn)) void argv_exec(exec_t *e)
exit(EXIT_FAILURE);
}
-static int run_sequentially(exec_t *list)
+static int run_sequentially(exec_t *list, bool direct_exec_last)
{
pid_t ret, pid;
int status;
for (; list != NULL; list = list->next) {
- if (list->next == NULL)
+ if (list->next == NULL && direct_exec_last)
argv_exec(list);
pid = fork();
@@ -169,6 +169,7 @@ pid_t runsvc(service_t *svc)
{
sigset_t mask;
pid_t pid;
+ int ret;
pid = fork();
@@ -190,7 +191,15 @@ pid_t runsvc(service_t *svc)
exit(EXIT_FAILURE);
}
- exit(run_sequentially(svc->exec));
+ if (svc->flags & SVC_FLAG_SUB_REAPER) {
+ prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0);
+
+ ret = run_sequentially(svc->exec, false);
+ } else {
+ ret = run_sequentially(svc->exec, true);
+ }
+
+ exit(ret);
}
return pid;