aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/term.c b/src/term.c
index 481a3423989..28b944c6436 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1,6 +1,6 @@
1/* Terminal control module for terminals described by TERMCAP 1/* Terminal control module for terminals described by TERMCAP
2 Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2012 2 Copyright (C) 1985-1987, 1993-1995, 1998, 2000-2013 Free Software
3 Free Software Foundation, Inc. 3 Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -953,8 +953,8 @@ tty_ins_del_lines (struct frame *f, int vpos, int n)
953 const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; 953 const char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line;
954 const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; 954 const char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll;
955 955
956 register int i = n > 0 ? n : -n; 956 int i = eabs (n);
957 register char *buf; 957 char *buf;
958 958
959 /* If the lines below the insertion are being pushed 959 /* If the lines below the insertion are being pushed
960 into the end of the window, this is the same as clearing; 960 into the end of the window, this is the same as clearing;
@@ -1321,7 +1321,7 @@ term_get_fkeys_1 (void)
1321 if (!KEYMAPP (KVAR (kboard, Vinput_decode_map))) 1321 if (!KEYMAPP (KVAR (kboard, Vinput_decode_map)))
1322 kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil)); 1322 kset_input_decode_map (kboard, Fmake_sparse_keymap (Qnil));
1323 1323
1324 for (i = 0; i < (sizeof (keys)/sizeof (keys[0])); i++) 1324 for (i = 0; i < (sizeof (keys) / sizeof (keys[0])); i++)
1325 { 1325 {
1326 char *sequence = tgetstr (keys[i].cap, address); 1326 char *sequence = tgetstr (keys[i].cap, address);
1327 if (sequence) 1327 if (sequence)
@@ -2374,7 +2374,7 @@ A suspended tty may be resumed by calling `resume-tty' on it. */)
2374 t->display_info.tty->output = 0; 2374 t->display_info.tty->output = 0;
2375 2375
2376 if (FRAMEP (t->display_info.tty->top_frame)) 2376 if (FRAMEP (t->display_info.tty->top_frame))
2377 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0); 2377 SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 0);
2378 2378
2379 } 2379 }
2380 2380
@@ -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+");
@@ -2444,7 +2444,7 @@ frame's terminal). */)
2444 get_tty_size (fileno (t->display_info.tty->input), &width, &height); 2444 get_tty_size (fileno (t->display_info.tty->input), &width, &height);
2445 if (width != old_width || height != old_height) 2445 if (width != old_width || height != old_height)
2446 change_frame_size (f, height, width, 0, 0, 0); 2446 change_frame_size (f, height, width, 0, 0, 0);
2447 FRAME_SET_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1); 2447 SET_FRAME_VISIBLE (XFRAME (t->display_info.tty->top_frame), 1);
2448 } 2448 }
2449 2449
2450 set_tty_hooks (t); 2450 set_tty_hooks (t);
@@ -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. */
2907static void 2907static void
2908dissociate_if_controlling_tty (int fd) 2908dissociate_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 (tcgetpgrp (fd) >= 0 && 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 {
@@ -3362,10 +3367,6 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\
3362 = tty->TS_delete_mode && tty->TS_insert_mode 3367 = tty->TS_delete_mode && tty->TS_insert_mode
3363 && !strcmp (tty->TS_delete_mode, tty->TS_insert_mode); 3368 && !strcmp (tty->TS_delete_mode, tty->TS_insert_mode);
3364 3369
3365 tty->se_is_so = (tty->TS_standout_mode
3366 && tty->TS_end_standout_mode
3367 && !strcmp (tty->TS_standout_mode, tty->TS_end_standout_mode));
3368
3369 UseTabs (tty) = tabs_safe_p (fileno (tty->input)) && TabWidth (tty) == 8; 3370 UseTabs (tty) = tabs_safe_p (fileno (tty->input)) && TabWidth (tty) == 8;
3370 3371
3371 terminal->scroll_region_ok 3372 terminal->scroll_region_ok
@@ -3425,9 +3426,6 @@ maybe_fatal (int must_succeed, struct terminal *terminal,
3425 vfatal (str2, ap); 3426 vfatal (str2, ap);
3426 else 3427 else
3427 verror (str1, ap); 3428 verror (str1, ap);
3428
3429 va_end (ap);
3430 emacs_abort ();
3431} 3429}
3432 3430
3433void 3431void
@@ -3436,7 +3434,6 @@ fatal (const char *str, ...)
3436 va_list ap; 3434 va_list ap;
3437 va_start (ap, str); 3435 va_start (ap, str);
3438 vfatal (str, ap); 3436 vfatal (str, ap);
3439 va_end (ap);
3440} 3437}
3441 3438
3442 3439