Skip to content

Commit ac4b9c2

Browse files
committed
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 <[email protected]>
1 parent 5e9591d commit ac4b9c2

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ All relevant changes are documented in this file.
2020
the default `SIGTERM`
2121
- Fix pre/post/ready/cleanup script execution if service has an
2222
optional `env:file` (leading `-`)
23+
- Fix blocked signals for pre/post/ready/cleanup scripts preventing
24+
normal shutdown when a service/sysv is stopped in its setup state
2325

2426

2527
[4.10][] - 2025-03-03

src/service.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,8 @@ static void service_pre_script(svc_t *svc)
21552155
strlcpy(buf, svc->pre_script, sizeof(buf));
21562156

21572157
set_pre_post_envs(svc, "pre");
2158+
sig_unblock();
2159+
21582160
execvp(_PATH_BSHELL, argv);
21592161
_exit(EX_OSERR);
21602162
}
@@ -2192,6 +2194,7 @@ static void service_post_script(svc_t *svc)
21922194
else
21932195
strlcpy(buf, svc->post_script, sizeof(buf));
21942196
set_pre_post_envs(svc, "post");
2197+
sig_unblock();
21952198

21962199
if (WIFEXITED(svc->status)) {
21972200
char val[4];
@@ -2253,6 +2256,8 @@ void service_ready_script(svc_t *svc)
22532256
strlcpy(buf, svc->ready_script, sizeof(buf));
22542257

22552258
set_pre_post_envs(svc, "ready");
2259+
sig_unblock();
2260+
22562261
execvp(_PATH_BSHELL, argv);
22572262
_exit(EX_OSERR);
22582263
}
@@ -2289,6 +2294,8 @@ static void service_cleanup_script(svc_t *svc)
22892294
strlcpy(buf, svc->cleanup_script, sizeof(buf));
22902295

22912296
set_pre_post_envs(svc, "cleanup");
2297+
sig_unblock();
2298+
22922299
execvp(_PATH_BSHELL, argv);
22932300
_exit(EX_OSERR);
22942301
}

0 commit comments

Comments
 (0)