]> git.eshelyaron.com Git - emacs.git/commitdiff
Signals can be captured by any thread.
authorGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 17 Sep 2009 09:40:18 +0000 (11:40 +0200)
committerGiuseppe Scrivano <gscrivano@gnu.org>
Thu, 17 Sep 2009 09:40:18 +0000 (11:40 +0200)
src/syssignal.h
src/thread.c
src/thread.h

index f435d33859470f36edee202d54f2c31272e7a790..cab36900017b5423cbb9494a863a24cee99a1338 100644 (file)
@@ -180,7 +180,7 @@ char *strsignal ();
 #ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
 #define SIGNAL_THREAD_CHECK(signo)                                      \
   do {                                                                  \
-    if (!pthread_equal (pthread_self (), main_thread))                 \
+    if (!user_thread_p ())                                             \
       {                                                                 \
         /* POSIX says any thread can receive the signal.  On GNU/Linux  \
            that is not true, but for other systems (FreeBSD at least)   \
index 36f075dc6461b1d92feb3327cb091985a334b8a1..2bcea5c54a50eee3cced3e559b6fb8841140b741 100644 (file)
@@ -162,6 +162,7 @@ run_thread (void *state)
   self->m_specpdl = xmalloc (self->m_specpdl_size
                             * sizeof (struct specbinding));
   self->m_specpdl_ptr = self->m_specpdl;
+  self->pthread_id = pthread_self ();
 
   /* Thread-local assignment.  */
   current_thread = self;
@@ -262,6 +263,23 @@ get_main_thread (void)
   return result;
 }
 
+/* Is the current an user thread.  */
+int
+user_thread_p (void)
+{
+  struct thread_state *it = all_threads;
+  pthread_t self = pthread_self ();
+  do
+    {
+      if (it->pthread_id == self)
+       return 1;
+    }
+  while (it = it->next_thread);
+
+  return 0;
+}
+
+
 int
 other_threads_p (void)
 {
@@ -273,6 +291,7 @@ init_threads (void)
 {
   pthread_mutex_init (&global_lock, NULL);
   pthread_mutex_lock (&global_lock);
+  primary_thread.pthread_id = pthread_self ();
 }
 
 void
index 8f7b02ba2dae6467d47439d94ee7a4707c447652..69e801f9a3f2e5b0a0ef1d93ea13ec3b5c7e667e 100644 (file)
@@ -69,6 +69,8 @@ struct thread_state
 #define current_buffer (current_thread->m_current_buffer)
 
   struct thread_state *next_thread;
+
+  pthread_t pthread_id;
 };
 
 extern __thread struct thread_state *current_thread;
@@ -86,3 +88,5 @@ extern Lisp_Object get_main_thread P_ ((void));
 extern pthread_mutex_t global_lock;
 
 extern int other_threads_p P_ ((void));
+
+extern int user_thread_p P_ ((void));