From 56beb0f015e664fbfb66268969d33d7c7b6558bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Rodr=C3=ADguez?= Date: Mon, 17 Aug 2026 15:22:43 +0200 Subject: [PATCH] GNU Classpath: Use pthread_sigmask() to set the signal mask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit classlibInitialiseSignalMask() uses sigprocmask(), whose effect in multithreaded processes is unspecified by POSIX. This is OK when the function is called by the initial thread, as at that point the VM is effectively still single-threaded, but not when it is called for externally created threads that attach through JNI. Fix this by using pthread_sigmask() instead. This was originally generic code: commit 089a6a0 ("OpenJDK: Do not block signals") made signal mask initialisation classlib-specific, retaining the previously shared code for GNU Classpath, while the new OpenJDK implementation already used pthread_sigmask() correctly. Signed-off-by: Guillermo Rodríguez --- src/classlib/gnuclasspath/thread.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classlib/gnuclasspath/thread.c b/src/classlib/gnuclasspath/thread.c index b6abc73..feff30c 100644 --- a/src/classlib/gnuclasspath/thread.c +++ b/src/classlib/gnuclasspath/thread.c @@ -150,7 +150,7 @@ void classlibInitialiseSignalMask() { sigaddset(&mask, SIGQUIT); sigaddset(&mask, SIGINT); sigaddset(&mask, SIGPIPE); - sigprocmask(SIG_BLOCK, &mask, NULL); + pthread_sigmask(SIG_BLOCK, &mask, NULL); } void classlibSignalThread(Thread *self) {