prims.cc (_Jv_CreateJavaVM): Add comment about initialization order.
authorDavid Daney <ddaney@avtrex.com>
Wed, 16 Feb 2005 04:16:06 +0000 (04:16 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Wed, 16 Feb 2005 04:16:06 +0000 (04:16 +0000)
2005-02-15  David Daney <ddaney@avtrex.com>
            Bryce McKinlay  <mckinlay@redhat.com>

* prims.cc (_Jv_CreateJavaVM): Add comment about initialization order.
* posix-threads.cc (_Jv_InitThreads): Call block_sigchld() here to
ensure that GC threads inherit the new signal mask.
(block_sigchld): Call JvFail rather than throwing exception if
pthread_sigmask() fails.

Co-Authored-By: Bryce McKinlay <mckinlay@redhat.com>
From-SVN: r95095

libjava/ChangeLog
libjava/posix-threads.cc
libjava/prims.cc

index 249641f64b5daa20c0d3fa581e93b6baa9528638..abc0d70bd84b049737b2da0eb38366b05e59ea41 100644 (file)
@@ -1,3 +1,12 @@
+2005-02-15  David Daney <ddaney@avtrex.com>
+           Bryce McKinlay  <mckinlay@redhat.com>
+           
+       * prims.cc (_Jv_CreateJavaVM): Add comment about initialization order.
+       * posix-threads.cc (_Jv_InitThreads): Call block_sigchld() here to
+       ensure that GC threads inherit the new signal mask.
+       (block_sigchld): Call JvFail rather than throwing exception if
+       pthread_sigmask() fails.
+
 2005-02-15  Mark Wielaard  <mark@klomp.org>
 
        * java/util/jar/Attributes.java (Name.CLASS_PATH): Document that
index 0643c1a5c7b86053055652661f3c4bb808b99440..91da25cf38de9d9fe49557993aa7a30b33b941f5 100644 (file)
@@ -281,6 +281,17 @@ handle_intr (int)
   // Do nothing.
 }
 
+static void
+block_sigchld()
+{
+  sigset_t mask;
+  sigemptyset (&mask);
+  sigaddset (&mask, SIGCHLD);
+  int c = pthread_sigmask (SIG_BLOCK, &mask, NULL);
+  if (c != 0)
+    JvFail (strerror (c));
+}
+
 void
 _Jv_InitThreads (void)
 {
@@ -296,6 +307,10 @@ _Jv_InitThreads (void)
   sigemptyset (&act.sa_mask);
   act.sa_flags = 0;
   sigaction (INTR, &act, NULL);
+
+  // Block SIGCHLD here to ensure that any non-Java threads inherit the new 
+  // signal mask.
+  block_sigchld();
 }
 
 _Jv_Thread_t *
@@ -333,17 +348,6 @@ _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)
 {
index c3c07d9f5e5b377d93e81d134d6c099e110ee28e..d12a2428ef0a6deb0f72f720149e1213673e1432 100644 (file)
@@ -921,6 +921,8 @@ _Jv_CreateJavaVM (void* /*vm_args*/)
 
   PROCESS_GCJ_PROPERTIES;
 
+  /* Threads must be initialized before the GC, so that it inherits the
+     signal mask.  */
   _Jv_InitThreads ();
   _Jv_InitGC ();
   _Jv_InitializeSyncMutex ();