It sounds like this has been broken ever since multi-tty was
added to Emacs.
* src/keyboard.c (dev_tty): New global variable.
* src/keyboard.h: Declare 'dev_tty'.
* src/emacs.c (main): Initialize 'dev_tty'.
* src/term.c (Fcontrolling_tty_p, Fresume_tty, init_tty):
* src/process.c (dissociate_controlling_tty):
* src/keyboard.c (handle_interrupt_signal, handle_interrupt)
(Fset_quit_char): Use 'dev_tty' instead of 'DEV_TTY'. (Bug#70519)
(cherry picked from commit
fa0f65aa342e181e0e98f55cbf5d9a9be5ed3be6)
inhibit_window_system = 0;
/* Handle the -t switch, which specifies filename to use as terminal. */
+ dev_tty = xstrdup (DEV_TTY); /* the default terminal */
while (!only_version)
{
char *term;
exit (EXIT_FAILURE);
}
fprintf (stderr, "Using %s\n", term);
+ xfree (dev_tty);
+ dev_tty = xstrdup (term);
#ifdef HAVE_WINDOW_SYSTEM
inhibit_window_system = true; /* -t => -nw */
#endif
#else
char const DEV_TTY[] = "/dev/tty";
#endif
+char *dev_tty; /* set by init_keyboard */
/* Variables for blockinput.h: */
handle_interrupt_signal (int sig)
{
/* See if we have an active terminal on our controlling tty. */
- struct terminal *terminal = get_named_terminal (DEV_TTY);
+ struct terminal *terminal = get_named_terminal (dev_tty);
if (!terminal)
{
/* If there are no frames there, let's pretend that we are a
cancel_echoing ();
/* XXX This code needs to be revised for multi-tty support. */
- if (!NILP (Vquit_flag) && get_named_terminal (DEV_TTY))
+ if (!NILP (Vquit_flag) && get_named_terminal (dev_tty))
{
if (! in_signal_handler)
{
See also `current-input-mode'. */)
(Lisp_Object quit)
{
- struct terminal *t = get_named_terminal (DEV_TTY);
+ struct terminal *t = get_named_terminal (dev_tty);
struct tty_display_info *tty;
if (!t)
extern const char *const lispy_function_keys[];
#endif
+/* Terminal device used by Emacs for terminal I/O. */
+extern char *dev_tty;
+/* Initial value for dev_tty. */
extern char const DEV_TTY[];
INLINE_HEADER_END
child that has not execed.
I wonder: would just ioctl (fd, TIOCNOTTY, 0) work here, for
some fd that the caller already has? */
- int ttyfd = emacs_open (DEV_TTY, O_RDWR, 0);
+ int ttyfd = emacs_open (dev_tty, O_RDWR, 0);
if (0 <= ttyfd)
{
ioctl (ttyfd, TIOCNOTTY, 0);
{
struct terminal *t = decode_tty_terminal (terminal);
- return (t && !strcmp (t->display_info.tty->name, DEV_TTY) ? Qt : Qnil);
+ return (t && !strcmp (t->display_info.tty->name, dev_tty) ? Qt : Qnil);
}
DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0,
open_errno);
}
- if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, DEV_TTY) != 0)
+ if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, dev_tty) != 0)
dissociate_if_controlling_tty (fd);
#endif /* MSDOS */
/* Create a termcap display on the tty device with the given name and
type.
- If NAME is NULL, then use the controlling tty, i.e., DEV_TTY.
+ If NAME is NULL, then use the controlling tty, i.e., dev_tty.
Otherwise NAME should be a path to the tty device file,
e.g. "/dev/pts/7".
"Unknown terminal type");
if (name == NULL)
- name = DEV_TTY;
+ name = dev_tty;
#ifndef DOS_NT
- if (!strcmp (name, DEV_TTY))
+ if (!strcmp (name, dev_tty))
ctty = 1;
#endif