Unblock signals for pre/post/ready/cleanup scripts

The service_fork() function blocks all signals for the new process, it
is up to the callee to call sig_unblock() before calling exec().

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2025-03-27 19:10:56 +01:00
parent 5e9591d0a8
commit ac4b9c2f93
2 changed files with 9 additions and 0 deletions
+2
View File
@@ -20,6 +20,8 @@ All relevant changes are documented in this file.
the default `SIGTERM`
- Fix pre/post/ready/cleanup script execution if service has an
optional `env:file` (leading `-`)
- Fix blocked signals for pre/post/ready/cleanup scripts preventing
normal shutdown when a service/sysv is stopped in its setup state
[4.10][] - 2025-03-03
+7
View File
@@ -2155,6 +2155,8 @@ static void service_pre_script(svc_t *svc)
strlcpy(buf, svc->pre_script, sizeof(buf));
set_pre_post_envs(svc, "pre");
sig_unblock();
execvp(_PATH_BSHELL, argv);
_exit(EX_OSERR);
}
@@ -2192,6 +2194,7 @@ static void service_post_script(svc_t *svc)
else
strlcpy(buf, svc->post_script, sizeof(buf));
set_pre_post_envs(svc, "post");
sig_unblock();
if (WIFEXITED(svc->status)) {
char val[4];
@@ -2253,6 +2256,8 @@ void service_ready_script(svc_t *svc)
strlcpy(buf, svc->ready_script, sizeof(buf));
set_pre_post_envs(svc, "ready");
sig_unblock();
execvp(_PATH_BSHELL, argv);
_exit(EX_OSERR);
}
@@ -2289,6 +2294,8 @@ static void service_cleanup_script(svc_t *svc)
strlcpy(buf, svc->cleanup_script, sizeof(buf));
set_pre_post_envs(svc, "cleanup");
sig_unblock();
execvp(_PATH_BSHELL, argv);
_exit(EX_OSERR);
}