re GNATS gcj/51 (Writing on OutputStream of bad Socket kills app with "Broken pipe")
authorTom Tromey <tromey@cygnus.com>
Thu, 23 Sep 1999 18:50:59 +0000 (18:50 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 23 Sep 1999 18:50:59 +0000 (18:50 +0000)
* prims.cc (main_init): New function.
(JvRunMain): Call it.
(_Jv_RunMain): Likewise.
Include <signal.h>.
(main_init): Ignore SIGPIPE.  Fixes PR 51.

From-SVN: r29625

libjava/ChangeLog
libjava/prims.cc

index 133fbf323f63663a0f8e714b9987dfb3d7a06aeb..906d69b0ca9da2b724fd363e1cccb4eba021b631 100644 (file)
@@ -1,3 +1,11 @@
+1999-09-23  Tom Tromey  <tromey@cygnus.com>
+
+       * prims.cc (main_init): New function.
+       (JvRunMain): Call it.
+       (_Jv_RunMain): Likewise.
+       Include <signal.h>.
+       (main_init): Ignore SIGPIPE.  Fixes PR 51.
+
 1999-09-22  Tom Tromey  <tromey@cygnus.com>
 
        * libgcj.spec.in: Use `jc1' spec, not `cc1' spec.
index 39d8d763d766d30e4102d038ef40ae65a3fa8e76..39357a24d852c40e16f0fc97906c5c481ef58603 100644 (file)
@@ -14,6 +14,7 @@ details.  */
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include <signal.h>
 
 #pragma implementation "gcj/array.h"
 
@@ -595,8 +596,8 @@ static java::lang::ThreadGroup *main_group;
 // The primary thread.
 static java::lang::Thread *main_thread;
 
-void
-JvRunMain (jclass klass, int argc, const char **argv)
+static void
+main_init (void)
 {
   INIT_SEGV;
 #ifdef HANDLE_FPE
@@ -612,6 +613,19 @@ JvRunMain (jclass klass, int argc, const char **argv)
   LTDL_SET_PRELOADED_SYMBOLS ();
 #endif
 
+  // FIXME: we only want this on POSIX systems.
+  struct sigaction act;
+  act.sa_handler = SIG_IGN;
+  sigemptyset (&act.sa_mask);
+  act.sa_flags = 0;
+  sigaction (SIGPIPE, &act, NULL);
+}
+
+void
+JvRunMain (jclass klass, int argc, const char **argv)
+{
+  main_init ();
+
   arg_vec = JvConvertArgv (argc - 1, argv + 1);
   main_group = new java::lang::ThreadGroup (23);
   main_thread = new java::lang::FirstThread (main_group, klass, arg_vec);
@@ -625,19 +639,7 @@ JvRunMain (jclass klass, int argc, const char **argv)
 void
 _Jv_RunMain (const char *class_name, int argc, const char **argv)
 {
-  INIT_SEGV;
-#ifdef HANDLE_FPE
-  INIT_FPE;
-#else
-  arithexception = new java::lang::ArithmeticException
-    (JvNewStringLatin1 ("/ by zero"));
-#endif
-
-  no_memory = new java::lang::OutOfMemoryError;
-
-#ifdef USE_LTDL
-  LTDL_SET_PRELOADED_SYMBOLS ();
-#endif
+  main_init ();
 
   arg_vec = JvConvertArgv (argc - 1, argv + 1);
   main_group = new java::lang::ThreadGroup (23);