mirror of
https://github.com/troglobit/finit.git
synced 2026-11-10 16:31:21 +00:00
Minor refactor, split out pre/post envs
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
f930953e6a
commit
fd9f204b6d
1 file changed
+10
-2
+10
-2
@@ -1548,6 +1548,14 @@ static void service_kill_script(svc_t *svc)
|
|||||||
kill(-svc->pid, SIGKILL);
|
kill(-svc->pid, SIGKILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shared env vars for both pre: and post: scripts
|
||||||
|
*/
|
||||||
|
static void set_pre_post_envs(svc_t *svc)
|
||||||
|
{
|
||||||
|
setenv("SERVICE_IDENT", svc_ident(svc, NULL, 0), 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void service_pre_script(svc_t *svc)
|
static void service_pre_script(svc_t *svc)
|
||||||
{
|
{
|
||||||
svc->pid = service_fork(svc);
|
svc->pid = service_fork(svc);
|
||||||
@@ -1564,7 +1572,7 @@ static void service_pre_script(svc_t *svc)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
setenv("SERVICE_IDENT", svc_ident(svc, NULL, 0), 1);
|
set_pre_post_envs(svc);
|
||||||
execvp(_PATH_BSHELL, argv);
|
execvp(_PATH_BSHELL, argv);
|
||||||
_exit(EX_OSERR);
|
_exit(EX_OSERR);
|
||||||
}
|
}
|
||||||
@@ -1593,7 +1601,7 @@ static void service_post_script(svc_t *svc)
|
|||||||
rc = WEXITSTATUS(svc->status);
|
rc = WEXITSTATUS(svc->status);
|
||||||
sig = WTERMSIG(svc->status);
|
sig = WTERMSIG(svc->status);
|
||||||
|
|
||||||
setenv("SERVICE_IDENT", svc_ident(svc, NULL, 0), 1);
|
set_pre_post_envs(svc);
|
||||||
|
|
||||||
if (WIFEXITED(svc->status)) {
|
if (WIFEXITED(svc->status)) {
|
||||||
char val[4];
|
char val[4];
|
||||||
|
|||||||
Reference in new issue
Block a user