s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 6920ddc814d709bc60c162c1fef794b108940e95
parent 28f5b4e7a5cce43198269f26583e66a232a976b5
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Sat, 20 Aug 2022 14:13:22 +0000

 Pass service name as an argument to the service script

Signed-off-by: Laurent Bercot <ska@appnovation.com>

Diffstat:
Msrc/supervision/s6-supervise.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c @@ -62,6 +62,7 @@ static state_t state = DOWN ; static int flagdying = 0 ; static int cont = 1 ; static int notifyfd = -1 ; +static char const *servicename = 0 ; static inline void settimeout (int secs) { @@ -305,7 +306,7 @@ static void trystart (void) } else if (!pid) { - char const *cargv[2] = { "run", 0 } ; + char const *cargv[3] = { "run", servicename, 0 } ; ((char *)PROG)[strlen(PROG)] = ' ' ; selfpipe_finish() ; if (notifyp[0] >= 0) close(notifyp[0]) ; @@ -455,7 +456,7 @@ static int uplastup_z (void) { char fmt0[UINT_FMT] ; char fmt1[UINT_FMT] ; - char *cargv[4] = { "finish", fmt0, fmt1, 0 } ; + char *cargv[5] = { "finish", fmt0, fmt1, servicename, 0 } ; selfpipe_finish() ; fmt0[uint_fmt(fmt0, WIFSIGNALED(status.wstat) ? 256 : WEXITSTATUS(status.wstat))] = 0 ; fmt1[uint_fmt(fmt1, WTERMSIG(status.wstat))] = 0 ; @@ -765,6 +766,7 @@ int main (int argc, char const *const *argv) PROG = "s6-supervise" ; if (argc < 2) strerr_dieusage(100, USAGE) ; if (chdir(argv[1]) < 0) strerr_diefu2sys(111, "chdir to ", argv[1]) ; + servicename = argv[1] ; { size_t proglen = strlen(PROG) ; size_t namelen = strlen(argv[1]) ;