]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 63111] Ensure output-sync is cleaned on re-exec and recursion
authorAndreas Schwab <schwab@suse.de>
Sat, 1 Oct 2022 16:47:42 +0000 (12:47 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 2 Oct 2022 12:46:00 +0000 (08:46 -0400)
Now that output-sync is using a separate file as a mutex rather than
stdout, ensure the new file descriptor is closed before re-exec and
not inherited by children.

* src/main.c (main): Call osync_clear() before re-exec.
* src/posixos.c (osync_setup): Reset output-sync handle inheritance.
(osync_parse_mutex): Ditto.

Copyright-paperwork-exempt: yes

src/main.c
src/posixos.c

index 3821089cbfac6f428cfb5135149e0f50a454101b..2daf2dba60a675ee7cf3bb937a1604e07ad7be57 100644 (file)
@@ -2727,6 +2727,8 @@ main (int argc, char **argv, char **envp)
           fflush (stdout);
           fflush (stderr);
 
+          osync_clear();
+
           /* The exec'd "child" will be another make, of course.  */
           jobserver_pre_child(1);
 
index d587f9c85449ea71ea5ae9478bbf37abc0e3c1c3..c6500efa506da6ff0dd0624a3454c0800e3c8f75 100644 (file)
@@ -462,7 +462,7 @@ jobserver_acquire (int timeout)
           case EBADF:
             /* Someone closed the jobs pipe.
                That shouldn't happen but if it does we're done.  */
-              O (fatal, NILF, _("job server shut down"));
+            O (fatal, NILF, _("job server shut down"));
 
           default:
             pfatal_with_name (_("pselect jobs pipe"));
@@ -628,7 +628,10 @@ osync_setup ()
 {
   osync_handle = get_tmpfd (&osync_tmpfile);
   if (osync_handle >= 0)
-    sync_parent = 1;
+    {
+      fd_noinherit (osync_handle);
+      sync_parent = 1;
+    }
 }
 
 char *
@@ -662,6 +665,8 @@ osync_parse_mutex (const char *mutex)
     OSS (fatal, NILF, _("cannot open output sync mutex %s: %s"),
          osync_tmpfile, strerror (errno));
 
+  fd_noinherit (osync_handle);
+
   return 1;
 }