diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2013-01-10 18:40:58 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2013-01-10 18:40:58 -0800 |
commit | b895642720aaf1d89e22c7cdda11990919622a72 (patch) | |
tree | 319a9a095ad702cbb7c93eb0a127444fd7874805 /src/sysdep.c | |
parent | a778dd57d0da9004a72320f8082d4f6220f178e2 (diff) | |
download | emacs-b895642720aaf1d89e22c7cdda11990919622a72.tar.gz |
emacsclient -t should not suspend Emacs server
* lisp.h, sysdep.c (block_tty_out_signal, unblock_tty_out_signal):
New functions.
* term.c (init_tty): Use them instead of rolling our own code.
* sysdep.c (tcsetpgrp_without_stopping): Likewise. Here, this
switches from 'signal' to 'pthread_sigmask', which is safer in
multithreaded applications.
* term.c (Fresume_tty): Don't bother dissociating if O_IGNORE_CTTY,
which has already arranged for that.
(dissociate_if_controlling_tty): If setsid fails, fall back on TIOCNOTTY.
This is the main part of the bug fix.
Fixes: debbugs:13387
Diffstat (limited to 'src/sysdep.c')
-rw-r--r-- | src/sysdep.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 049eb85afe5..158d2f73eec 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -714,6 +714,27 @@ init_foreground_group (void) inherited_pgroup = getpid () == pgrp ? 0 : pgrp; } +/* Block and unblock SIGTTOU. */ + +void +block_tty_out_signal (void) +{ +#ifdef SIGTTOU + sigset_t blocked; + sigemptyset (&blocked); + sigaddset (&blocked, SIGTTOU); + pthread_sigmask (SIG_BLOCK, &blocked, 0); +#endif +} + +void +unblock_tty_out_signal (void) +{ +#ifdef SIGTTOU + pthread_sigmask (SIG_SETMASK, &empty_mask, 0); +#endif +} + /* Safely set a controlling terminal FD's process group to PGID. If we are not in the foreground already, POSIX requires tcsetpgrp to deliver a SIGTTOU signal, which would stop us. This is an @@ -725,11 +746,10 @@ static void tcsetpgrp_without_stopping (int fd, pid_t pgid) { #ifdef SIGTTOU - signal_handler_t handler; block_input (); - handler = signal (SIGTTOU, SIG_IGN); + block_tty_out_signal (); tcsetpgrp (fd, pgid); - signal (SIGTTOU, handler); + unblock_tty_out_signal (); unblock_input (); #endif } |