aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorEli Zaretskii2016-12-19 19:11:16 +0200
committerEli Zaretskii2016-12-19 19:11:16 +0200
commitfe3188b1cecc7ac5534616c8edf14a84b1b3bbb0 (patch)
tree39041b114c679f98255e9c95f2b4666d6f269ab2 /src/sysdep.c
parent657bcaf5ac30449915e070c3fa80a2eaaf1ee7e1 (diff)
downloademacs-fe3188b1cecc7ac5534616c8edf14a84b1b3bbb0.tar.gz
emacs-fe3188b1cecc7ac5534616c8edf14a84b1b3bbb0.zip
Fix crashes upon C-g on Posix TTY frames
* src/thread.h (struct thread_state): New member not_holding_lock. (maybe_reacquire_global_lock): Add prototype. * src/thread.c: Include syssignal.h. (maybe_reacquire_global_lock): New function. (really_call_select): Set the not_holding_lock member of the thread state before releasing the lock, and rest it after re-acquiring the lock when the select function returns. Block SIGINT while doing this to make sure we are not interrupted on TTY frames. * src/sysdep.c (block_interrupt_signal, restore_signal_mask): New functions. * src/syssignal.h (block_interrupt_signal, restore_signal_mask): Add prototypes. * src/keyboard.c (read_char) [THREADS_ENABLED]: Call maybe_reacquire_global_lock. (Bug#25178)
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 3d2b9bdeeee..96c9e538409 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -765,6 +765,23 @@ unblock_child_signal (sigset_t const *oldset)
765 pthread_sigmask (SIG_SETMASK, oldset, 0); 765 pthread_sigmask (SIG_SETMASK, oldset, 0);
766} 766}
767 767
768/* Block SIGINT. */
769void
770block_interrupt_signal (sigset_t *oldset)
771{
772 sigset_t blocked;
773 sigemptyset (&blocked);
774 sigaddset (&blocked, SIGINT);
775 pthread_sigmask (SIG_BLOCK, &blocked, oldset);
776}
777
778/* Restore previously saved signal mask. */
779void
780restore_signal_mask (sigset_t const *oldset)
781{
782 pthread_sigmask (SIG_SETMASK, oldset, 0);
783}
784
768#endif /* !MSDOS */ 785#endif /* !MSDOS */
769 786
770/* Saving and restoring the process group of Emacs's terminal. */ 787/* Saving and restoring the process group of Emacs's terminal. */