diff options
| author | Joakim Verona | 2013-01-12 00:04:04 +0100 |
|---|---|---|
| committer | Joakim Verona | 2013-01-12 00:04:04 +0100 |
| commit | c655adbbab4baf73b652c86dcc53a2fc049ea7a5 (patch) | |
| tree | b3198033222acb2c309652a0e11590f109d037c6 /src/sysdep.c | |
| parent | 26f277ba01010776e63623d446f182f5b6f23dd3 (diff) | |
| parent | c88be99696aa39e3aed1e32ada7bf6e0cc472c90 (diff) | |
| download | emacs-c655adbbab4baf73b652c86dcc53a2fc049ea7a5.tar.gz emacs-c655adbbab4baf73b652c86dcc53a2fc049ea7a5.zip | |
auto upstream
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) | |||
| 714 | inherited_pgroup = getpid () == pgrp ? 0 : pgrp; | 714 | inherited_pgroup = getpid () == pgrp ? 0 : pgrp; |
| 715 | } | 715 | } |
| 716 | 716 | ||
| 717 | /* Block and unblock SIGTTOU. */ | ||
| 718 | |||
| 719 | void | ||
| 720 | block_tty_out_signal (void) | ||
| 721 | { | ||
| 722 | #ifdef SIGTTOU | ||
| 723 | sigset_t blocked; | ||
| 724 | sigemptyset (&blocked); | ||
| 725 | sigaddset (&blocked, SIGTTOU); | ||
| 726 | pthread_sigmask (SIG_BLOCK, &blocked, 0); | ||
| 727 | #endif | ||
| 728 | } | ||
| 729 | |||
| 730 | void | ||
| 731 | unblock_tty_out_signal (void) | ||
| 732 | { | ||
| 733 | #ifdef SIGTTOU | ||
| 734 | pthread_sigmask (SIG_SETMASK, &empty_mask, 0); | ||
| 735 | #endif | ||
| 736 | } | ||
| 737 | |||
| 717 | /* Safely set a controlling terminal FD's process group to PGID. | 738 | /* Safely set a controlling terminal FD's process group to PGID. |
| 718 | If we are not in the foreground already, POSIX requires tcsetpgrp | 739 | If we are not in the foreground already, POSIX requires tcsetpgrp |
| 719 | to deliver a SIGTTOU signal, which would stop us. This is an | 740 | to deliver a SIGTTOU signal, which would stop us. This is an |
| @@ -725,11 +746,10 @@ static void | |||
| 725 | tcsetpgrp_without_stopping (int fd, pid_t pgid) | 746 | tcsetpgrp_without_stopping (int fd, pid_t pgid) |
| 726 | { | 747 | { |
| 727 | #ifdef SIGTTOU | 748 | #ifdef SIGTTOU |
| 728 | signal_handler_t handler; | ||
| 729 | block_input (); | 749 | block_input (); |
| 730 | handler = signal (SIGTTOU, SIG_IGN); | 750 | block_tty_out_signal (); |
| 731 | tcsetpgrp (fd, pgid); | 751 | tcsetpgrp (fd, pgid); |
| 732 | signal (SIGTTOU, handler); | 752 | unblock_tty_out_signal (); |
| 733 | unblock_input (); | 753 | unblock_input (); |
| 734 | #endif | 754 | #endif |
| 735 | } | 755 | } |