Skip to content

Commit 4253d0d

Browse files
committed
Run service stop: and reload: scripts as non-blocking processes
A reload: script, like 'frrinit.sh reload' could potentially take a while to finish, during which Finit would be blocked. This change reuses the service_script_add(), used for ready: scripts, to track these background helpers. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent d47181a commit 4253d0d

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

src/service.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,6 @@ static int service_run_script(svc_t *svc, char *script)
10311031
{
10321032
const char *id = svc_ident(svc, NULL, 0);
10331033
pid_t pid = service_fork(svc);
1034-
int status, rc;
10351034

10361035
if (pid < 0) {
10371036
err(1, "%s: failed forking off script %s", id, script);
@@ -1047,6 +1046,8 @@ static int service_run_script(svc_t *svc, char *script)
10471046
};
10481047
char pidbuf[16];
10491048

1049+
redirect(svc);
1050+
10501051
snprintf(pidbuf, sizeof(pidbuf), "%d", svc->pid);
10511052
setenv("MAINPID", pidbuf, 1);
10521053

@@ -1056,23 +1057,7 @@ static int service_run_script(svc_t *svc, char *script)
10561057
}
10571058

10581059
dbg("%s: script '%s' started as PID %d", id, script, pid);
1059-
if (waitpid(pid, &status, 0) == -1) {
1060-
warn("%s: failed calling script %s", id, script);
1061-
return -1;
1062-
}
1063-
1064-
rc = WEXITSTATUS(status);
1065-
if (WIFEXITED(status)) {
1066-
dbg("%s: script '%s' exited without signal, status: %d", id, script, rc);
1067-
} else if (WIFSIGNALED(status)) {
1068-
dbg("%s: script '%s' terminated by signal %d", id, script, WTERMSIG(status));
1069-
if (!rc)
1070-
rc = 1;
1071-
} else {
1072-
dbg("%s: script '%s' exited with status: %d", id, script, rc);
1073-
}
1074-
1075-
return rc;
1060+
return service_script_add(svc, pid, svc->killdelay);
10761061
}
10771062

10781063
/* Ensure we don't have any notify socket lingering */

0 commit comments

Comments
 (0)