diff --git a/src/thread.c b/src/thread.c index c03cdda0fae..1ded8f55f50 100644 --- a/src/thread.c +++ b/src/thread.c @@ -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); }