summaryrefslogtreecommitdiff
path: root/libjava/posix-threads.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/posix-threads.cc')
-rw-r--r--libjava/posix-threads.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/libjava/posix-threads.cc b/libjava/posix-threads.cc
index 03ae4535a05..0643c1a5c7b 100644
--- a/libjava/posix-threads.cc
+++ b/libjava/posix-threads.cc
@@ -1,6 +1,6 @@
// posix-threads.cc - interface between libjava and POSIX threads.
-/* Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2004 Free Software Foundation
This file is part of libgcj.
@@ -34,6 +34,7 @@ details. */
#include <java/lang/System.h>
#include <java/lang/Long.h>
#include <java/lang/OutOfMemoryError.h>
+#include <java/lang/InternalError.h>
// This is used to implement thread startup.
struct starter
@@ -332,6 +333,17 @@ _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio)
#endif
}
+static void
+block_sigchld()
+{
+ sigset_t mask;
+ sigemptyset (&mask);
+ sigaddset (&mask, SIGCHLD);
+ int c = pthread_sigmask (SIG_BLOCK, &mask, NULL);
+ if (c != 0)
+ throw new java::lang::InternalError (JvNewStringUTF (strerror (c)));
+}
+
void
_Jv_ThreadRegister (_Jv_Thread_t *data)
{
@@ -358,6 +370,8 @@ _Jv_ThreadRegister (_Jv_Thread_t *data)
_Jv_self_cache[current_index].high_sp_bits = BAD_HIGH_SP_VALUE;
}
# endif
+ // Block SIGCHLD which is used in natPosixProcess.cc.
+ block_sigchld();
}
void
@@ -403,6 +417,10 @@ _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
return;
data->flags |= FLAG_START;
+ // Block SIGCHLD which is used in natPosixProcess.cc.
+ // The current mask is inherited by the child thread.
+ block_sigchld();
+
param.sched_priority = thread->getPriority();
pthread_attr_init (&attr);