]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 63248] Ignore SIGPIPE
authorDmitry Goncharov <dgoncharov@users.sf.net>
Fri, 21 Oct 2022 22:54:39 +0000 (18:54 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 22 Oct 2022 13:45:40 +0000 (09:45 -0400)
Don't terminate when make's output is redirected to a pipe and the
reader exits early; e.g.:
  $ echo 'all:; sleep 2' | make -f- -j2 -O |:

This lets us unlink temporary files, and tell the user that make was
not able to write its output.
Reported by Frank Heckenbach <f.heckenbach@fh-soft.de>.

* src/main.c (main): Ignore SIGPIPE.
* src/posixos.c (osync_clear): Fix a memory leak.

src/main.c
src/posixos.c

index 509253fa0767c01b0ba4542cd8f7e47c87a523d1..ba44fd6713e01d0328e9f1572d9cc085c9a0e030 100644 (file)
@@ -1182,6 +1182,11 @@ main (int argc, char **argv, char **envp)
   /* Useful for attaching debuggers, etc.  */
   SPIN ("main-entry");
 
+  /* Don't die if our stdout sends us SIGPIPE.  */
+#ifdef SIGPIPE
+  bsd_signal (SIGPIPE, SIG_IGN);
+#endif
+
 #ifdef HAVE_ATEXIT
   if (ANY_SET (check_io_state (), IO_STDOUT_OK))
     atexit (close_stdout);
index a48116dbe682cfaec697b2284979683776233ee8..fca3192749993a133f998437415cc078e288ce71 100644 (file)
@@ -699,6 +699,7 @@ osync_clear ()
       int r;
 
       EINTRLOOP (r, unlink (osync_tmpfile));
+      free (osync_tmpfile);
       osync_tmpfile = NULL;
     }
 }