1 /* rltty.c -- functions to prepare and restore the terminal for readline's
4 /* Copyright (C) 1992-2005 Free Software Foundation, Inc.
6 This file is part of the GNU Readline Library (Readline), a library
7 for reading lines of text with interactive input and history editing.
9 Readline is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Readline is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Readline. If not, see <http://www.gnu.org/licenses/>.
23 #define READLINE_LIBRARY
25 #if defined (HAVE_CONFIG_H)
29 #include <sys/types.h>
34 #if defined (HAVE_UNISTD_H)
36 #endif /* HAVE_UNISTD_H */
40 #if defined (GWINSZ_IN_SYS_IOCTL)
41 # include <sys/ioctl.h>
42 #endif /* GWINSZ_IN_SYS_IOCTL */
46 #include "rlprivate.h"
52 rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
53 rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
55 static void set_winsize PARAMS((int));
57 /* **************************************************************** */
59 /* Saving and Restoring the TTY */
61 /* **************************************************************** */
63 /* Non-zero means that the terminal is in a prepped state. */
64 static int terminal_prepped;
66 static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
68 /* If non-zero, means that this process has called tcflow(fd, TCOOFF)
69 and output is suspended. */
70 #if defined (__ksr1__)
74 /* Dummy call to force a backgrounded readline to stop before it tries
75 to get the tty settings. */
80 #if defined (TIOCGWINSZ)
83 if (ioctl (tty, TIOCGWINSZ, &w) == 0)
84 (void) ioctl (tty, TIOCSWINSZ, &w);
85 #endif /* TIOCGWINSZ */
88 #if defined (NO_TTY_DRIVER)
90 #elif defined (NEW_TTY_DRIVER)
92 /* Values for the `flags' field of a struct bsdtty. This tells which
93 elements of the struct bsdtty have been fetched from the system and
95 #define SGTTY_SET 0x01
96 #define LFLAG_SET 0x02
97 #define TCHARS_SET 0x04
98 #define LTCHARS_SET 0x08
101 struct sgttyb sgttyb; /* Basic BSD tty driver information. */
102 int lflag; /* Local mode flags, like LPASS8. */
103 #if defined (TIOCGETC)
104 struct tchars tchars; /* Terminal special characters, including ^S and ^Q. */
106 #if defined (TIOCGLTC)
107 struct ltchars ltchars; /* 4.2 BSD editing characters */
109 int flags; /* Bitmap saying which parts of the struct are valid. */
112 #define TIOTYPE struct bsdtty
116 static void save_tty_chars PARAMS((TIOTYPE *));
117 static int _get_tty_settings PARAMS((int, TIOTYPE *));
118 static int get_tty_settings PARAMS((int, TIOTYPE *));
119 static int _set_tty_settings PARAMS((int, TIOTYPE *));
120 static int set_tty_settings PARAMS((int, TIOTYPE *));
122 static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
124 static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
127 save_tty_chars (tiop)
130 _rl_last_tty_chars = _rl_tty_chars;
132 if (tiop->flags & SGTTY_SET)
134 _rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
135 _rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
138 if (tiop->flags & TCHARS_SET)
140 _rl_intr_char = _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
141 _rl_quit_char = _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
143 _rl_tty_chars.t_start = tiop->tchars.t_startc;
144 _rl_tty_chars.t_stop = tiop->tchars.t_stopc;
145 _rl_tty_chars.t_eof = tiop->tchars.t_eofc;
146 _rl_tty_chars.t_eol = '\n';
147 _rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
150 if (tiop->flags & LTCHARS_SET)
152 _rl_susp_char = _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
154 _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
155 _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
156 _rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
157 _rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
158 _rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
161 _rl_tty_chars.t_status = -1;
165 get_tty_settings (tty, tiop)
171 tiop->flags = tiop->lflag = 0;
174 if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
176 tiop->flags |= SGTTY_SET;
178 #if defined (TIOCLGET)
179 if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
180 tiop->flags |= LFLAG_SET;
183 #if defined (TIOCGETC)
184 if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
185 tiop->flags |= TCHARS_SET;
188 #if defined (TIOCGLTC)
189 if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
190 tiop->flags |= LTCHARS_SET;
197 set_tty_settings (tty, tiop)
201 if (tiop->flags & SGTTY_SET)
203 ioctl (tty, TIOCSETN, &(tiop->sgttyb));
204 tiop->flags &= ~SGTTY_SET;
208 #if defined (TIOCLSET)
209 if (tiop->flags & LFLAG_SET)
211 ioctl (tty, TIOCLSET, &(tiop->lflag));
212 tiop->flags &= ~LFLAG_SET;
216 #if defined (TIOCSETC)
217 if (tiop->flags & TCHARS_SET)
219 ioctl (tty, TIOCSETC, &(tiop->tchars));
220 tiop->flags &= ~TCHARS_SET;
224 #if defined (TIOCSLTC)
225 if (tiop->flags & LTCHARS_SET)
227 ioctl (tty, TIOCSLTC, &(tiop->ltchars));
228 tiop->flags &= ~LTCHARS_SET;
236 prepare_terminal_settings (meta_flag, oldtio, tiop)
238 TIOTYPE oldtio, *tiop;
240 _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
241 _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
243 /* Copy the original settings to the structure we're going to use for
245 tiop->sgttyb = oldtio.sgttyb;
246 tiop->lflag = oldtio.lflag;
247 #if defined (TIOCGETC)
248 tiop->tchars = oldtio.tchars;
250 #if defined (TIOCGLTC)
251 tiop->ltchars = oldtio.ltchars;
253 tiop->flags = oldtio.flags;
255 /* First, the basic settings to put us into character-at-a-time, no-echo
257 tiop->sgttyb.sg_flags &= ~(ECHO | CRMOD);
258 tiop->sgttyb.sg_flags |= CBREAK;
260 /* If this terminal doesn't care how the 8th bit is used, then we can
261 use it for the meta-key. If only one of even or odd parity is
262 specified, then the terminal is using parity, and we cannot. */
264 # define ANYP (EVENP | ODDP)
266 if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
267 ((oldtio.sgttyb.sg_flags & ANYP) == 0))
269 tiop->sgttyb.sg_flags |= ANYP;
271 /* Hack on local mode flags if we can. */
272 #if defined (TIOCLGET)
273 # if defined (LPASS8)
274 tiop->lflag |= LPASS8;
276 #endif /* TIOCLGET */
279 #if defined (TIOCGETC)
280 # if defined (USE_XON_XOFF)
281 /* Get rid of terminal output start and stop characters. */
282 tiop->tchars.t_stopc = -1; /* C-s */
283 tiop->tchars.t_startc = -1; /* C-q */
285 /* If there is an XON character, bind it to restart the output. */
286 if (oldtio.tchars.t_startc != -1)
287 rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
288 # endif /* USE_XON_XOFF */
290 /* If there is an EOF char, bind _rl_eof_char to it. */
291 if (oldtio.tchars.t_eofc != -1)
292 _rl_eof_char = oldtio.tchars.t_eofc;
294 # if defined (NO_KILL_INTR)
295 /* Get rid of terminal-generated SIGQUIT and SIGINT. */
296 tiop->tchars.t_quitc = -1; /* C-\ */
297 tiop->tchars.t_intrc = -1; /* C-c */
298 # endif /* NO_KILL_INTR */
299 #endif /* TIOCGETC */
301 #if defined (TIOCGLTC)
302 /* Make the interrupt keys go away. Just enough to make people happy. */
303 tiop->ltchars.t_dsuspc = -1; /* C-y */
304 tiop->ltchars.t_lnextc = -1; /* C-v */
305 #endif /* TIOCGLTC */
308 #else /* !defined (NEW_TTY_DRIVER) */
318 #if defined (TERMIOS_TTY_DRIVER)
319 # define TIOTYPE struct termios
320 # define DRAIN_OUTPUT(fd) tcdrain (fd)
321 # define GETATTR(tty, tiop) (tcgetattr (tty, tiop))
323 # define SETATTR(tty, tiop) (tcsetattr (tty, TCSANOW, tiop))
325 # define SETATTR(tty, tiop) (tcsetattr (tty, TCSADRAIN, tiop))
326 # endif /* !M_UNIX */
328 # define TIOTYPE struct termio
329 # define DRAIN_OUTPUT(fd)
330 # define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop))
331 # define SETATTR(tty, tiop) (ioctl (tty, TCSETAW, tiop))
332 #endif /* !TERMIOS_TTY_DRIVER */
336 static void save_tty_chars PARAMS((TIOTYPE *));
337 static int _get_tty_settings PARAMS((int, TIOTYPE *));
338 static int get_tty_settings PARAMS((int, TIOTYPE *));
339 static int _set_tty_settings PARAMS((int, TIOTYPE *));
340 static int set_tty_settings PARAMS((int, TIOTYPE *));
342 static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
344 static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
345 static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
348 # define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO)
350 # define OUTPUT_BEING_FLUSHED(tp) 0
354 save_tty_chars (tiop)
357 _rl_last_tty_chars = _rl_tty_chars;
359 _rl_tty_chars.t_eof = tiop->c_cc[VEOF];
360 _rl_tty_chars.t_eol = tiop->c_cc[VEOL];
362 _rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
364 _rl_tty_chars.t_erase = tiop->c_cc[VERASE];
366 _rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
368 _rl_tty_chars.t_kill = tiop->c_cc[VKILL];
370 _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
372 _rl_intr_char = _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
373 _rl_quit_char = _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
375 _rl_susp_char = _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
378 _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
381 _rl_tty_chars.t_start = tiop->c_cc[VSTART];
384 _rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
387 _rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
390 _rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
393 _rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
397 #if defined (_AIX) || defined (_AIX41)
398 /* Currently this is only used on AIX */
403 _rl_errmsg ("warning: %s", msg);
412 if ((tp->c_oflag & OPOST) == 0)
414 _rl_errmsg ("warning: turning on OPOST for terminal\r");
415 tp->c_oflag |= OPOST|ONLCR;
421 _get_tty_settings (tty, tiop)
429 ioctl_ret = GETATTR (tty, tiop);
437 if (OUTPUT_BEING_FLUSHED (tiop))
440 _rl_errmsg ("warning: turning off output flushing");
441 tiop->c_lflag &= ~FLUSHO;
454 get_tty_settings (tty, tiop)
461 if (_get_tty_settings (tty, tiop) < 0)
472 _set_tty_settings (tty, tiop)
476 while (SETATTR (tty, tiop) < 0)
486 set_tty_settings (tty, tiop)
490 if (_set_tty_settings (tty, tiop) < 0)
495 #if defined (TERMIOS_TTY_DRIVER)
496 # if defined (__ksr1__)
503 tcflow (tty, TCOON); /* Simulate a ^Q. */
506 ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
507 #endif /* !TERMIOS_TTY_DRIVER */
515 prepare_terminal_settings (meta_flag, oldtio, tiop)
517 TIOTYPE oldtio, *tiop;
519 _rl_echoing_p = (oldtio.c_lflag & ECHO);
520 #if defined (ECHOCTL)
521 _rl_echoctl = (oldtio.c_lflag & ECHOCTL);
524 tiop->c_lflag &= ~(ICANON | ECHO);
526 if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
527 _rl_eof_char = oldtio.c_cc[VEOF];
529 #if defined (USE_XON_XOFF)
531 tiop->c_iflag &= ~(IXON | IXOFF | IXANY);
533 /* `strict' Posix systems do not define IXANY. */
534 tiop->c_iflag &= ~(IXON | IXOFF);
536 #endif /* USE_XON_XOFF */
538 /* Only turn this off if we are using all 8 bits. */
539 if (((tiop->c_cflag & CSIZE) == CS8) || meta_flag)
540 tiop->c_iflag &= ~(ISTRIP | INPCK);
542 /* Make sure we differentiate between CR and NL on input. */
543 tiop->c_iflag &= ~(ICRNL | INLCR);
545 #if !defined (HANDLE_SIGNALS)
546 tiop->c_lflag &= ~ISIG;
548 tiop->c_lflag |= ISIG;
551 tiop->c_cc[VMIN] = 1;
552 tiop->c_cc[VTIME] = 0;
555 if (OUTPUT_BEING_FLUSHED (tiop))
557 tiop->c_lflag &= ~FLUSHO;
558 oldtio.c_lflag &= ~FLUSHO;
562 /* Turn off characters that we need on Posix systems with job control,
563 just to be sure. This includes ^Y and ^V. This should not really
565 #if defined (TERMIOS_TTY_DRIVER) && defined (_POSIX_VDISABLE)
568 tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
572 tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
575 #endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
577 #endif /* !NEW_TTY_DRIVER */
579 /* Put the terminal in CBREAK mode so that we can detect key presses. */
580 #if defined (NO_TTY_DRIVER)
582 rl_prep_terminal (meta_flag)
589 rl_deprep_terminal ()
593 #else /* ! NO_TTY_DRIVER */
595 rl_prep_terminal (meta_flag)
601 if (terminal_prepped)
604 /* Try to keep this function from being INTerrupted. */
607 tty = rl_instream ? fileno (rl_instream) : fileno (stdin);
609 if (get_tty_settings (tty, &tio) < 0)
611 #if defined (ENOTSUP)
612 /* MacOS X and Linux, at least, lie about the value of errno if
614 if (errno == ENOTTY || errno == EINVAL || errno == ENOTSUP)
616 if (errno == ENOTTY || errno == EINVAL)
618 _rl_echoing_p = 1; /* XXX */
620 _rl_release_sigint ();
626 if (_rl_bind_stty_chars)
628 #if defined (VI_MODE)
629 /* If editing in vi mode, make sure we restore the bindings in the
630 insertion keymap no matter what keymap we ended up in. */
631 if (rl_editing_mode == vi_mode)
632 rl_tty_unset_default_bindings (vi_insertion_keymap);
635 rl_tty_unset_default_bindings (_rl_keymap);
637 save_tty_chars (&otio);
638 RL_SETSTATE(RL_STATE_TTYCSAVED);
639 if (_rl_bind_stty_chars)
641 #if defined (VI_MODE)
642 /* If editing in vi mode, make sure we set the bindings in the
643 insertion keymap no matter what keymap we ended up in. */
644 if (rl_editing_mode == vi_mode)
645 _rl_bind_tty_special_chars (vi_insertion_keymap, tio);
648 _rl_bind_tty_special_chars (_rl_keymap, tio);
651 prepare_terminal_settings (meta_flag, otio, &tio);
653 if (set_tty_settings (tty, &tio) < 0)
655 _rl_release_sigint ();
659 if (_rl_enable_keypad)
660 _rl_control_keypad (1);
662 fflush (rl_outstream);
663 terminal_prepped = 1;
664 RL_SETSTATE(RL_STATE_TERMPREPPED);
666 _rl_release_sigint ();
669 /* Restore the terminal's normal settings and modes. */
671 rl_deprep_terminal ()
675 if (!terminal_prepped)
678 /* Try to keep this function from being interrupted. */
681 tty = rl_instream ? fileno (rl_instream) : fileno (stdout);
683 if (_rl_enable_keypad)
684 _rl_control_keypad (0);
686 fflush (rl_outstream);
688 if (set_tty_settings (tty, &otio) < 0)
690 _rl_release_sigint ();
694 terminal_prepped = 0;
695 RL_UNSETSTATE(RL_STATE_TERMPREPPED);
697 _rl_release_sigint ();
699 #endif /* !NO_TTY_DRIVER */
701 /* **************************************************************** */
703 /* Bogus Flow Control */
705 /* **************************************************************** */
708 rl_restart_output (count, key)
711 #if defined (__MINGW32__)
713 #else /* !__MING32__ */
715 int fildes = fileno (rl_outstream);
716 #if defined (TIOCSTART)
718 ioctl (&fildes, TIOCSTART, 0);
720 ioctl (fildes, TIOCSTART, 0);
723 #else /* !TIOCSTART */
724 # if defined (TERMIOS_TTY_DRIVER)
725 # if defined (__ksr1__)
729 tcflow (fildes, TCOON);
732 tcflow (fildes, TCOON); /* Simulate a ^Q. */
734 # else /* !TERMIOS_TTY_DRIVER */
735 # if defined (TCXONC)
736 ioctl (fildes, TCXONC, TCOON);
738 # endif /* !TERMIOS_TTY_DRIVER */
739 #endif /* !TIOCSTART */
742 #endif /* !__MINGW32__ */
746 rl_stop_output (count, key)
749 #if defined (__MINGW32__)
753 int fildes = fileno (rl_instream);
755 #if defined (TIOCSTOP)
756 # if defined (apollo)
757 ioctl (&fildes, TIOCSTOP, 0);
759 ioctl (fildes, TIOCSTOP, 0);
761 #else /* !TIOCSTOP */
762 # if defined (TERMIOS_TTY_DRIVER)
763 # if defined (__ksr1__)
766 tcflow (fildes, TCOOFF);
768 # if defined (TCXONC)
769 ioctl (fildes, TCXONC, TCOON);
771 # endif /* !TERMIOS_TTY_DRIVER */
772 #endif /* !TIOCSTOP */
775 #endif /* !__MINGW32__ */
778 /* **************************************************************** */
780 /* Default Key Bindings */
782 /* **************************************************************** */
784 #if !defined (NO_TTY_DRIVER)
785 #define SET_SPECIAL(sc, func) set_special_char(kmap, &ttybuff, sc, func)
788 #if defined (NO_TTY_DRIVER)
790 #define SET_SPECIAL(sc, func)
791 #define RESET_SPECIAL(c)
793 #elif defined (NEW_TTY_DRIVER)
795 set_special_char (kmap, tiop, sc, func)
799 rl_command_func_t *func;
801 if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC)
802 kmap[(unsigned char)sc].function = func;
805 #define RESET_SPECIAL(c) \
806 if (c != -1 && kmap[(unsigned char)c].type == ISFUNC) \
807 kmap[(unsigned char)c].function = rl_insert;
810 _rl_bind_tty_special_chars (kmap, ttybuff)
814 if (ttybuff.flags & SGTTY_SET)
816 SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
817 SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
820 # if defined (TIOCGLTC)
821 if (ttybuff.flags & LTCHARS_SET)
823 SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
824 SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
826 # endif /* TIOCGLTC */
829 #else /* !NEW_TTY_DRIVER */
831 set_special_char (kmap, tiop, sc, func)
835 rl_command_func_t *func;
840 if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC)
841 kmap[uc].function = func;
845 #define RESET_SPECIAL(uc) \
846 if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
847 kmap[uc].function = rl_insert;
850 _rl_bind_tty_special_chars (kmap, ttybuff)
854 SET_SPECIAL (VERASE, rl_rubout);
855 SET_SPECIAL (VKILL, rl_unix_line_discard);
857 # if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
858 SET_SPECIAL (VLNEXT, rl_quoted_insert);
859 # endif /* VLNEXT && TERMIOS_TTY_DRIVER */
861 # if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
862 SET_SPECIAL (VWERASE, rl_unix_word_rubout);
863 # endif /* VWERASE && TERMIOS_TTY_DRIVER */
866 #endif /* !NEW_TTY_DRIVER */
868 /* Set the system's default editing characters to their readline equivalents
869 in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */
871 rltty_set_default_bindings (kmap)
874 #if !defined (NO_TTY_DRIVER)
878 tty = fileno (rl_instream);
880 if (get_tty_settings (tty, &ttybuff) == 0)
881 _rl_bind_tty_special_chars (kmap, ttybuff);
885 /* New public way to set the system default editing chars to their readline
888 rl_tty_set_default_bindings (kmap)
891 rltty_set_default_bindings (kmap);
894 /* Rebind all of the tty special chars that readline worries about back
895 to self-insert. Call this before saving the current terminal special
896 chars with save_tty_chars(). This only works on POSIX termios or termio
899 rl_tty_unset_default_bindings (kmap)
902 /* Don't bother before we've saved the tty special chars at least once. */
903 if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0)
906 RESET_SPECIAL (_rl_tty_chars.t_erase);
907 RESET_SPECIAL (_rl_tty_chars.t_kill);
909 # if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
910 RESET_SPECIAL (_rl_tty_chars.t_lnext);
911 # endif /* VLNEXT && TERMIOS_TTY_DRIVER */
913 # if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
914 RESET_SPECIAL (_rl_tty_chars.t_werase);
915 # endif /* VWERASE && TERMIOS_TTY_DRIVER */
918 #if defined (HANDLE_SIGNALS)
920 #if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
922 _rl_disable_tty_signals ()
928 _rl_restore_tty_signals ()
934 static TIOTYPE sigstty, nosigstty;
935 static int tty_sigs_disabled = 0;
938 _rl_disable_tty_signals ()
940 if (tty_sigs_disabled)
943 if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
948 nosigstty.c_lflag &= ~ISIG;
949 nosigstty.c_iflag &= ~IXON;
951 if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
952 return (_set_tty_settings (fileno (rl_instream), &sigstty));
954 tty_sigs_disabled = 1;
959 _rl_restore_tty_signals ()
963 if (tty_sigs_disabled == 0)
966 r = _set_tty_settings (fileno (rl_instream), &sigstty);
969 tty_sigs_disabled = 0;
973 #endif /* !NEW_TTY_DRIVER */
975 #endif /* HANDLE_SIGNALS */