From 9084f3862973aa5eccfafe51c6682a6aef123d4d Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 13 May 2020 17:08:54 +0200 Subject: Add utility functions for clearing/setting signal mask Signed-off-by: David Oberhollenzer --- initd/init.h | 1 + initd/runsvc.c | 7 ++----- initd/supervisor.c | 7 +++---- 3 files changed, 6 insertions(+), 9 deletions(-) (limited to 'initd') diff --git a/initd/init.h b/initd/init.h index 005fbba..ad681d9 100644 --- a/initd/init.h +++ b/initd/init.h @@ -22,6 +22,7 @@ #include "service.h" #include "config.h" +#include "util.h" #define ENVFILE ETCPATH "/initd.env" #define PROCFDDIR "/proc/self/fd" diff --git a/initd/runsvc.c b/initd/runsvc.c index 8aaa502..95c26cb 100644 --- a/initd/runsvc.c +++ b/initd/runsvc.c @@ -186,7 +186,6 @@ static int run_sequentially(exec_t *list, bool direct_exec_last) pid_t runsvc(service_t *svc) { struct sigaction act; - sigset_t mask; pid_t pid; int ret; @@ -196,8 +195,7 @@ pid_t runsvc(service_t *svc) perror("fork"); if (pid == 0) { - sigfillset(&mask); - sigprocmask(SIG_SETMASK, &mask, NULL); + cli(NULL); memset(&act, 0, sizeof(act)); act.sa_handler = runsvc_sighandler; @@ -220,8 +218,7 @@ pid_t runsvc(service_t *svc) exit(EXIT_FAILURE); } - sigemptyset(&mask); - sigprocmask(SIG_SETMASK, &mask, NULL); + sti(NULL); if (svc->flags & SVC_FLAG_SUB_REAPER) { prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0); diff --git a/initd/supervisor.c b/initd/supervisor.c index 1a131ac..43900a5 100644 --- a/initd/supervisor.c +++ b/initd/supervisor.c @@ -179,14 +179,13 @@ out: bool supervisor_process_queues(void) { - sigset_t mask, old_mask; svc_run_data_t *rt; + sigset_t old_mask; service_t *svc; size_t count; bool ret = false; - sigfillset(&mask); - sigprocmask(SIG_SETMASK, &mask, &old_mask); + cli(&old_mask); if (waiting) goto out_unblock; @@ -224,6 +223,6 @@ bool supervisor_process_queues(void) print_status(svc->desc, rt->state); check_target_completion(); out_unblock: - sigprocmask(SIG_SETMASK, &old_mask, NULL); + sti(&old_mask); return ret; } -- cgit v1.2.3