]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid a hang after C-g while sit-for on a Unix TTY
authorEli Zaretskii <eliz@gnu.org>
Fri, 24 Nov 2017 16:13:57 +0000 (18:13 +0200)
committerEli Zaretskii <eliz@gnu.org>
Fri, 24 Nov 2017 16:13:57 +0000 (18:13 +0200)
* src/thread.c (acquire_global_lock): Don't try to take the global
lock if the same thread is already holding it.  (Bug#29347)

src/thread.c

index c03cdda0fae9a9f31c74ed947a49bbb19253c128..1ded8f55f50ab5f45681211fc9fa5004a3e11305 100644 (file)
@@ -97,7 +97,12 @@ post_acquire_global_lock (struct thread_state *self)
 static void
 acquire_global_lock (struct thread_state *self)
 {
-  sys_mutex_lock (&global_lock);
+  /* If some Lisp was interrupted by C-g while inside pselect, the
+     signal handler could have called maybe_reacquire_global_lock, in
+     which case we are already holding the lock and shouldn't try
+     taking it again, or else we will hang forever.  */
+  if (!(self && self->not_holding_lock))
+    sys_mutex_lock (&global_lock);
   post_acquire_global_lock (self);
 }