aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2024-05-04 13:12:21 +0300
committerEli Zaretskii2024-05-04 13:12:21 +0300
commitfa0f65aa342e181e0e98f55cbf5d9a9be5ed3be6 (patch)
treef4f143f00f32a1cfb141aef2279b1bafdcdc9b5d /src
parent1121f17d7c4bc3b71edcd0799b894f50aa3a715e (diff)
downloademacs-fa0f65aa342e181e0e98f55cbf5d9a9be5ed3be6.tar.gz
emacs-fa0f65aa342e181e0e98f55cbf5d9a9be5ed3be6.zip
Fix implementation of the --terminal command-line switch
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)
Diffstat (limited to 'src')
-rw-r--r--src/emacs.c3
-rw-r--r--src/keyboard.c7
-rw-r--r--src/keyboard.h3
-rw-r--r--src/process.c2
-rw-r--r--src/term.c10
5 files changed, 16 insertions, 9 deletions
diff --git a/src/emacs.c b/src/emacs.c
index 7431cef274d..77e6c41e822 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1653,6 +1653,7 @@ main (int argc, char **argv)
1653 inhibit_window_system = 0; 1653 inhibit_window_system = 0;
1654 1654
1655 /* Handle the -t switch, which specifies filename to use as terminal. */ 1655 /* Handle the -t switch, which specifies filename to use as terminal. */
1656 dev_tty = xstrdup (DEV_TTY); /* the default terminal */
1656 while (!only_version) 1657 while (!only_version)
1657 { 1658 {
1658 char *term; 1659 char *term;
@@ -1675,6 +1676,8 @@ main (int argc, char **argv)
1675 exit (EXIT_FAILURE); 1676 exit (EXIT_FAILURE);
1676 } 1677 }
1677 fprintf (stderr, "Using %s\n", term); 1678 fprintf (stderr, "Using %s\n", term);
1679 xfree (dev_tty);
1680 dev_tty = xstrdup (term);
1678#ifdef HAVE_WINDOW_SYSTEM 1681#ifdef HAVE_WINDOW_SYSTEM
1679 inhibit_window_system = true; /* -t => -nw */ 1682 inhibit_window_system = true; /* -t => -nw */
1680#endif 1683#endif
diff --git a/src/keyboard.c b/src/keyboard.c
index a06c9116d24..69d29ededc0 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -98,6 +98,7 @@ char const DEV_TTY[] = "CONOUT$";
98#else 98#else
99char const DEV_TTY[] = "/dev/tty"; 99char const DEV_TTY[] = "/dev/tty";
100#endif 100#endif
101char *dev_tty; /* set by init_keyboard */
101 102
102/* Variables for blockinput.h: */ 103/* Variables for blockinput.h: */
103 104
@@ -12003,7 +12004,7 @@ static void
12003handle_interrupt_signal (int sig) 12004handle_interrupt_signal (int sig)
12004{ 12005{
12005 /* See if we have an active terminal on our controlling tty. */ 12006 /* See if we have an active terminal on our controlling tty. */
12006 struct terminal *terminal = get_named_terminal (DEV_TTY); 12007 struct terminal *terminal = get_named_terminal (dev_tty);
12007 if (!terminal) 12008 if (!terminal)
12008 { 12009 {
12009 /* If there are no frames there, let's pretend that we are a 12010 /* If there are no frames there, let's pretend that we are a
@@ -12072,7 +12073,7 @@ handle_interrupt (bool in_signal_handler)
12072 cancel_echoing (); 12073 cancel_echoing ();
12073 12074
12074 /* XXX This code needs to be revised for multi-tty support. */ 12075 /* XXX This code needs to be revised for multi-tty support. */
12075 if (!NILP (Vquit_flag) && get_named_terminal (DEV_TTY)) 12076 if (!NILP (Vquit_flag) && get_named_terminal (dev_tty))
12076 { 12077 {
12077 if (! in_signal_handler) 12078 if (! in_signal_handler)
12078 { 12079 {
@@ -12365,7 +12366,7 @@ process.
12365See also `current-input-mode'. */) 12366See also `current-input-mode'. */)
12366 (Lisp_Object quit) 12367 (Lisp_Object quit)
12367{ 12368{
12368 struct terminal *t = get_named_terminal (DEV_TTY); 12369 struct terminal *t = get_named_terminal (dev_tty);
12369 struct tty_display_info *tty; 12370 struct tty_display_info *tty;
12370 12371
12371 if (!t) 12372 if (!t)
diff --git a/src/keyboard.h b/src/keyboard.h
index 2ce003fd444..42637ca1cf7 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -521,6 +521,9 @@ extern void mark_kboards (void);
521extern const char *const lispy_function_keys[]; 521extern const char *const lispy_function_keys[];
522#endif 522#endif
523 523
524/* Terminal device used by Emacs for terminal I/O. */
525extern char *dev_tty;
526/* Initial value for dev_tty. */
524extern char const DEV_TTY[]; 527extern char const DEV_TTY[];
525 528
526INLINE_HEADER_END 529INLINE_HEADER_END
diff --git a/src/process.c b/src/process.c
index 6b8b483cdf7..50d1968200d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2114,7 +2114,7 @@ dissociate_controlling_tty (void)
2114 child that has not execed. 2114 child that has not execed.
2115 I wonder: would just ioctl (fd, TIOCNOTTY, 0) work here, for 2115 I wonder: would just ioctl (fd, TIOCNOTTY, 0) work here, for
2116 some fd that the caller already has? */ 2116 some fd that the caller already has? */
2117 int ttyfd = emacs_open (DEV_TTY, O_RDWR, 0); 2117 int ttyfd = emacs_open (dev_tty, O_RDWR, 0);
2118 if (0 <= ttyfd) 2118 if (0 <= ttyfd)
2119 { 2119 {
2120 ioctl (ttyfd, TIOCNOTTY, 0); 2120 ioctl (ttyfd, TIOCNOTTY, 0);
diff --git a/src/term.c b/src/term.c
index 6cb57592643..903444ef69f 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2312,7 +2312,7 @@ TERMINAL is not on a tty device. */)
2312{ 2312{
2313 struct terminal *t = decode_tty_terminal (terminal); 2313 struct terminal *t = decode_tty_terminal (terminal);
2314 2314
2315 return (t && !strcmp (t->display_info.tty->name, DEV_TTY) ? Qt : Qnil); 2315 return (t && !strcmp (t->display_info.tty->name, dev_tty) ? Qt : Qnil);
2316} 2316}
2317 2317
2318DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0, 2318DEFUN ("tty-no-underline", Ftty_no_underline, Stty_no_underline, 0, 1, 0,
@@ -2467,7 +2467,7 @@ frame's terminal). */)
2467 open_errno); 2467 open_errno);
2468 } 2468 }
2469 2469
2470 if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, DEV_TTY) != 0) 2470 if (!O_IGNORE_CTTY && strcmp (t->display_info.tty->name, dev_tty) != 0)
2471 dissociate_if_controlling_tty (fd); 2471 dissociate_if_controlling_tty (fd);
2472#endif /* MSDOS */ 2472#endif /* MSDOS */
2473 2473
@@ -4075,7 +4075,7 @@ dissociate_if_controlling_tty (int fd)
4075/* Create a termcap display on the tty device with the given name and 4075/* Create a termcap display on the tty device with the given name and
4076 type. 4076 type.
4077 4077
4078 If NAME is NULL, then use the controlling tty, i.e., DEV_TTY. 4078 If NAME is NULL, then use the controlling tty, i.e., dev_tty.
4079 Otherwise NAME should be a path to the tty device file, 4079 Otherwise NAME should be a path to the tty device file,
4080 e.g. "/dev/pts/7". 4080 e.g. "/dev/pts/7".
4081 4081
@@ -4114,9 +4114,9 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
4114 "Unknown terminal type"); 4114 "Unknown terminal type");
4115 4115
4116 if (name == NULL) 4116 if (name == NULL)
4117 name = DEV_TTY; 4117 name = dev_tty;
4118#ifndef DOS_NT 4118#ifndef DOS_NT
4119 if (!strcmp (name, DEV_TTY)) 4119 if (!strcmp (name, dev_tty))
4120 ctty = 1; 4120 ctty = 1;
4121#endif 4121#endif
4122 4122