[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Mark new threads as global signal receivers
From: |
Jeremie Koenig |
Subject: |
[PATCH] Mark new threads as global signal receivers |
Date: |
Wed, 25 May 2011 18:01:29 +0200 |
* sysdeps/mach/hurd/pt-sigstate-init.c (__pthread_sigstate_init):
Call _hurd_sigstate_set_global_rcv for newly created threads.
Declare it as a weak symbol so that we stay compatible with previous
glibc versions.
---
sysdeps/mach/hurd/pt-sigstate-init.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/sysdeps/mach/hurd/pt-sigstate-init.c
b/sysdeps/mach/hurd/pt-sigstate-init.c
index da5a945..811f7b3 100644
--- a/sysdeps/mach/hurd/pt-sigstate-init.c
+++ b/sysdeps/mach/hurd/pt-sigstate-init.c
@@ -19,9 +19,14 @@
#include <pthread.h>
#include <hurd/threadvar.h>
+#include <hurd/signal.h>
#include <pt-internal.h>
+/* Preserve compatibility with older glibc versions. */
+void _hurd_sigstate_set_global_rcv (struct hurd_sigstate *ss)
+ __attribute__((weak));
+
error_t
__pthread_sigstate_init (struct __pthread *thread)
{
@@ -30,8 +35,21 @@ __pthread_sigstate_init (struct __pthread *thread)
thread->stackaddr);
/* The real initialization happens internally in glibc the first
- time that _hurd_thead_sigstate is called. */
+ time that _hurd_self_sigstate is called. */
*location = 0;
+ /* Mark the thread as a global signal receiver so as to conform with
+ the pthread semantics. However, we must be careful. The first
+ pthread created is the main thread, during libpthread initialization.
+ We must not mark it, otherwise the sigprocmask call in
+ __pthread_create would try to access _hurd_global_sigstate,
+ which is not initialized yet. When glibc runs _hurdsig_init later
+ on, the message thread is created, which must not be marked either. */
+ if (_hurd_sigstate_set_global_rcv && __pthread_num_threads > 2)
+ {
+ struct hurd_sigstate *ss = _hurd_thread_sigstate (thread->kernel_thread);
+ _hurd_sigstate_set_global_rcv (ss);
+ }
+
return 0;
}
--
1.7.1