diff options
| author | Tom Tromey | 2013-01-16 11:48:32 -0700 |
|---|---|---|
| committer | Tom Tromey | 2013-01-16 11:48:32 -0700 |
| commit | 6f4de085f065e11f4df3195d47479f28f5ef08ba (patch) | |
| tree | 1211a00f1afc86c2b73624897993db02a4852943 /src/term.c | |
| parent | e078a23febca14bc919c5806670479c395e3253e (diff) | |
| parent | ffe04adc88e546c406f9b050238fb98a7243c7a0 (diff) | |
| download | emacs-6f4de085f065e11f4df3195d47479f28f5ef08ba.tar.gz emacs-6f4de085f065e11f4df3195d47479f28f5ef08ba.zip | |
merge from trunk
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/term.c b/src/term.c index d76562bb4db..f66a0bddc33 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -2423,7 +2423,7 @@ frame's terminal). */) | |||
| 2423 | if (fd == -1) | 2423 | if (fd == -1) |
| 2424 | error ("Can not reopen tty device %s: %s", t->display_info.tty->name, strerror (errno)); | 2424 | error ("Can not reopen tty device %s: %s", t->display_info.tty->name, strerror (errno)); |
| 2425 | 2425 | ||
| 2426 | if (strcmp (t->display_info.tty->name, DEV_TTY)) | 2426 | if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, DEV_TTY) != 0) |
| 2427 | dissociate_if_controlling_tty (fd); | 2427 | dissociate_if_controlling_tty (fd); |
| 2428 | 2428 | ||
| 2429 | t->display_info.tty->output = fdopen (fd, "w+"); | 2429 | t->display_info.tty->output = fdopen (fd, "w+"); |
| @@ -2903,13 +2903,23 @@ set_tty_hooks (struct terminal *terminal) | |||
| 2903 | terminal->delete_terminal_hook = &delete_tty; | 2903 | terminal->delete_terminal_hook = &delete_tty; |
| 2904 | } | 2904 | } |
| 2905 | 2905 | ||
| 2906 | /* Drop the controlling terminal if fd is the same device. */ | 2906 | /* If FD is the controlling terminal, drop it. */ |
| 2907 | static void | 2907 | static void |
| 2908 | dissociate_if_controlling_tty (int fd) | 2908 | dissociate_if_controlling_tty (int fd) |
| 2909 | { | 2909 | { |
| 2910 | pid_t pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */ | 2910 | /* If tcgetpgrp succeeds, fd is the controlling terminal, |
| 2911 | if (0 <= pgid) | 2911 | so dissociate it by invoking setsid. */ |
| 2912 | setsid (); | 2912 | if (0 <= tcgetpgrp (fd) && setsid () < 0) |
| 2913 | { | ||
| 2914 | #ifdef TIOCNOTTY | ||
| 2915 | /* setsid failed, presumably because Emacs is already a process | ||
| 2916 | group leader. Fall back on the obsolescent way to dissociate | ||
| 2917 | a controlling tty. */ | ||
| 2918 | block_tty_out_signal (); | ||
| 2919 | ioctl (fd, TIOCNOTTY, 0); | ||
| 2920 | unblock_tty_out_signal (); | ||
| 2921 | #endif | ||
| 2922 | } | ||
| 2913 | } | 2923 | } |
| 2914 | 2924 | ||
| 2915 | /* Create a termcap display on the tty device with the given name and | 2925 | /* Create a termcap display on the tty device with the given name and |
| @@ -3030,14 +3040,9 @@ init_tty (const char *name, const char *terminal_type, int must_succeed) | |||
| 3030 | 3040 | ||
| 3031 | /* On some systems, tgetent tries to access the controlling | 3041 | /* On some systems, tgetent tries to access the controlling |
| 3032 | terminal. */ | 3042 | terminal. */ |
| 3033 | { | 3043 | block_tty_out_signal (); |
| 3034 | sigset_t blocked; | 3044 | status = tgetent (tty->termcap_term_buffer, terminal_type); |
| 3035 | sigemptyset (&blocked); | 3045 | unblock_tty_out_signal (); |
| 3036 | sigaddset (&blocked, SIGTTOU); | ||
| 3037 | pthread_sigmask (SIG_BLOCK, &blocked, 0); | ||
| 3038 | status = tgetent (tty->termcap_term_buffer, terminal_type); | ||
| 3039 | pthread_sigmask (SIG_UNBLOCK, &blocked, 0); | ||
| 3040 | } | ||
| 3041 | 3046 | ||
| 3042 | if (status < 0) | 3047 | if (status < 0) |
| 3043 | { | 3048 | { |