re GNATS gcj/51 (Writing on OutputStream of bad Socket kills app with "Broken pipe")

* 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
This commit is contained in:
Tom Tromey 1999-09-23 18:50:59 +00:00 committed by Tom Tromey
parent fe1dbf6c7c
commit 9b0cb28706
2 changed files with 25 additions and 15 deletions

View 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.

View 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);