From: Ian Jackson Date: Sun, 17 Jul 2022 17:31:56 +0000 (+0100) Subject: prefork-interp: wip compile X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=3e731c159e5dca9bf1e2896f6d14cec438481faa;hp=04f03f380c5cc9413d3555c1740d7549052034bc;p=chiark-utils.git prefork-interp: wip compile Signed-off-by: Ian Jackson --- diff --git a/cprogs/prefork-interp.c b/cprogs/prefork-interp.c index 9e3c8fd..de63b42 100644 --- a/cprogs/prefork-interp.c +++ b/cprogs/prefork-interp.c @@ -336,9 +336,9 @@ static int connect_or_spawn(void) { r= bind(sfd, (const struct sockaddr*)&socket_sun, salen); if (r<0) diee("bind() on new listener"); - // We never want callers to get ECONNREFUSED!. + // We never want callers to get ECONNREFUSED. But: // There is a race here: from my RTFM they may get ECONNREFUSED - // if they tr between our bind() and listen(). But if they do, they'll + // if they try between our bind() and listen(). But if they do, they'll // acquire the lock (serialising with us) and retry, and then it will work. r = listen(sfd, INT_MAX); if (r<0) diee("listen() for new listener"); @@ -354,14 +354,15 @@ static int connect_or_spawn(void) { if (got == (pid_t)-1) diee("waitpid setup [%ld]", (long)setup_pid); if (got != setup_pid) diee("waitpid setup [%ld] gave [%ld]!", (long)setup_pid, (long)got); - if (status != 0) propagate_exit_status(status); + if (status != 0) propagate_exit_status(status, "invocation"); close(lockfd); return fake_pair[0]; } static void make_executor_argv(const char *const *argv) { - #define EACH_NEW_ARGV(EACH) { \ + const char *arg; + #define EACH_NEW_ARG(EACH) { \ arg = interp; { EACH } \ if ((arg = script)) { EACH } \ const char *const *walk = argv; \ @@ -369,13 +370,13 @@ static void make_executor_argv(const char *const *argv) { } size_t count = 1; - MAKE_NEW_ARGV( (void)arg; count++; ); + EACH_NEW_ARG( (void)arg; count++; ); - executor_argv = calloc(count, sizeof(char*)); + const char **out = calloc(count, sizeof(char*)); + executor_argv = (const char* const*)out; if (!executor_argv) diee("allocate for arguments"); - char **out = executor_argv; - MAKE_NEW_ARGV( *out++ = arg; ); + EACH_NEW_ARG( *out++ = arg; ); *out++ = 0; }