chiark / gitweb /
prefork-interp: wip compile
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Jul 2022 17:31:56 +0000 (18:31 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Aug 2022 20:21:10 +0000 (21:21 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cprogs/prefork-interp.c

index 9e3c8fd53eea3ea91105ed127fa5e21a790f846c..de63b42bf93445ab70897507a4755e560bb19eb7 100644 (file)
@@ -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;
 }