]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* src/output.c (_outputs): Don't use invalid output sync FDs
authorPaul Smith <psmith@gnu.org>
Mon, 24 Oct 2022 04:48:10 +0000 (00:48 -0400)
committerPaul Smith <psmith@gnu.org>
Mon, 24 Oct 2022 05:50:12 +0000 (01:50 -0400)
Just write to stdout/stderr in this situation.

src/output.c

index fa13e9c38cfece6ce226cfab59a3ac15b271c1f2..a88f537ac49df269c8d5776a98fb6c721997d4e5 100644 (file)
@@ -51,20 +51,24 @@ unsigned int stdio_traced = 0;
 static void
 _outputs (struct output *out, int is_err, const char *msg)
 {
-  if (! out || ! out->syncout)
-    {
-      FILE *f = is_err ? stderr : stdout;
-      fputs (msg, f);
-      fflush (f);
-    }
-  else
+  FILE *f;
+
+  if (out && out->syncout)
     {
       int fd = is_err ? out->err : out->out;
-      size_t len = strlen (msg);
-      int r;
-      EINTRLOOP (r, lseek (fd, 0, SEEK_END));
-      writebuf (fd, msg, len);
+      if (fd != OUTPUT_NONE)
+        {
+          size_t len = strlen (msg);
+          int r;
+          EINTRLOOP (r, lseek (fd, 0, SEEK_END));
+          writebuf (fd, msg, len);
+          return;
+        }
     }
+
+  f = is_err ? stderr : stdout;
+  fputs (msg, f);
+  fflush (f);
 }
 \f
 /* Write a message indicating that we've just entered or