(main): Set signal handler for SIGPIPE.
authorJim Wilson <wilson@gcc.gnu.org>
Tue, 12 Jan 1993 22:52:37 +0000 (14:52 -0800)
committerJim Wilson <wilson@gcc.gnu.org>
Tue, 12 Jan 1993 22:52:37 +0000 (14:52 -0800)
(pipe_closed): New function, to handle SIGPIPE.

From-SVN: r3205

gcc/cccp.c

index d3d4727369f04ea82f9c5525d20e3d7455dd0ca9..1036414f865b1f28e4d7727fe6311d29217750d6 100644 (file)
@@ -75,6 +75,7 @@ typedef unsigned char U_CHAR;
 #include <sys/stat.h>
 #include <ctype.h>
 #include <stdio.h>
+#include <signal.h>
 
 #ifndef VMS
 #ifndef USG
@@ -248,6 +249,7 @@ static void fatal ();
 void fancy_abort ();
 static void pfatal_with_name ();
 static void perror_with_name ();
+static void pipe_closed ();
 static void print_containing_files ();
 static int lookup_import ();
 static int redundant_include_p ();
@@ -983,6 +985,8 @@ main (argc, argv)
   }
 #endif /* RLIMIT_STACK defined */
 
+  signal (SIGPIPE, pipe_closed);
+
   progname = argv[0];
 #ifdef VMS
   {
@@ -8662,6 +8666,15 @@ pfatal_with_name (name)
 #endif
 }
 
+/* Handler for SIGPIPE.  */
+
+static void
+pipe_closed (signo)
+     /* If this is missing, some compilers complain.  */
+     int signo;
+{
+  fatal ("output pipe has been closed");
+}
 \f
 static void
 memory_full ()