aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorKaroly Lorentey2003-12-30 19:27:57 +0000
committerKaroly Lorentey2003-12-30 19:27:57 +0000
commit16c290d8c16fb0fdb574c837c6b1badbc655efe2 (patch)
tree26e7915477ebe5b8c3847e70b9230a6efa134e6c /src/sysdep.c
parent9d9f18127ffc1bc26358a5d48917ef4e4bafbddc (diff)
downloademacs-16c290d8c16fb0fdb574c837c6b1badbc655efe2.tar.gz
emacs-16c290d8c16fb0fdb574c837c6b1badbc655efe2.zip
Major bugfixes and slight enhancements.
src/dispextern.h (get_tty_size, tabs_safe_p, init_baud_rate): Update prototypes. src/dispnew.c (window_change_signal): Update call to get_tty_size. src/frame.c (Fmake_terminal_frame): Ditto. src/keyboard.c (Fsuspend_emacs): Ditto. src/sysdep.c: Eliminate tty_outputs, wherever possible. (The exceptions are init_sys_modes and reset_sys_modes, which need access to tty-local parameters). (init_baud_rate): Change tty_output parameter to a simple file descriptor. (narrow_foreground_group, widen_foreground_group): Ditto. (tabs_safe_p, get_tty_size): Ditto. (init_sys_modes): Update narrow_foreground_group invocation. (reset_sys_modes): Update widen_foreground_group invocation. (request_sigio)[!FASYNC && STRIDE]: Fix function signature. src/term.c (delete_tty): Only close output file handle if it is different from input. Re-enable freeing of Wcm. (term_init): Update get_tty_size, tabs_safe_p and init_baud_rate invocations. lib-src/emacsclient.c (here): Renamed to frame. (longopts): Change --here to --frame. The -h short option may be confused with --help. (decode_options, print_help_and_exit): Update to reflect above changes. (main): Ditto. lisp/server.el (server-start): Fix frame-live-p call syntax. (server-process-filter): Handle 'emacsclient -f' without file arguments. Don't return any values to emacsclient when 'emacsclient -f -e'. (server-switch-buffer): Prevent infinite recursion when there are no files to edit. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-27
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index b3a46c77eb3..7453be6e3a7 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -309,10 +309,13 @@ discard_tty_input ()
309#endif /* not WINDOWSNT */ 309#endif /* not WINDOWSNT */
310} 310}
311 311
312
312#ifdef SIGTSTP 313#ifdef SIGTSTP
313 314
314/* Arrange for character C to be read as the next input from 315/* Arrange for character C to be read as the next input from
315 the terminal. */ 316 the terminal.
317 XXX What if we have multiple ttys?
318*/
316 319
317void 320void
318stuff_char (char c) 321stuff_char (char c)
@@ -331,7 +334,7 @@ stuff_char (char c)
331#endif /* SIGTSTP */ 334#endif /* SIGTSTP */
332 335
333void 336void
334init_baud_rate (struct tty_output *tty) 337init_baud_rate (int fd)
335{ 338{
336 if (noninteractive) 339 if (noninteractive)
337 emacs_ospeed = 0; 340 emacs_ospeed = 0;
@@ -346,7 +349,7 @@ init_baud_rate (struct tty_output *tty)
346#ifdef VMS 349#ifdef VMS
347 struct sensemode sg; 350 struct sensemode sg;
348 351
349 SYS$QIOW (0, fileno (TTY_INPUT (tty)), IO$_SENSEMODE, &sg, 0, 0, 352 SYS$QIOW (0, fd, IO$_SENSEMODE, &sg, 0, 0,
350 &sg.class, 12, 0, 0, 0, 0 ); 353 &sg.class, 12, 0, 0, 0, 0 );
351 emacs_ospeed = sg.xmit_baud; 354 emacs_ospeed = sg.xmit_baud;
352#else /* not VMS */ 355#else /* not VMS */
@@ -354,7 +357,7 @@ init_baud_rate (struct tty_output *tty)
354 struct termios sg; 357 struct termios sg;
355 358
356 sg.c_cflag = B9600; 359 sg.c_cflag = B9600;
357 tcgetattr (fileno (TTY_INPUT (tty)), &sg); 360 tcgetattr (fd, &sg);
358 emacs_ospeed = cfgetospeed (&sg); 361 emacs_ospeed = cfgetospeed (&sg);
359#if defined (USE_GETOBAUD) && defined (getobaud) 362#if defined (USE_GETOBAUD) && defined (getobaud)
360 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ 363 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */
@@ -367,16 +370,16 @@ init_baud_rate (struct tty_output *tty)
367 370
368 sg.c_cflag = B9600; 371 sg.c_cflag = B9600;
369#ifdef HAVE_TCATTR 372#ifdef HAVE_TCATTR
370 tcgetattr (fileno (TTY_INPUT (tty)), &sg); 373 tcgetattr (fd, &sg);
371#else 374#else
372 ioctl (fileno (TTY_INPUT (tty)), TCGETA, &sg); 375 ioctl (fd, TCGETA, &sg);
373#endif 376#endif
374 emacs_ospeed = sg.c_cflag & CBAUD; 377 emacs_ospeed = sg.c_cflag & CBAUD;
375#else /* neither VMS nor TERMIOS nor TERMIO */ 378#else /* neither VMS nor TERMIOS nor TERMIO */
376 struct sgttyb sg; 379 struct sgttyb sg;
377 380
378 sg.sg_ospeed = B9600; 381 sg.sg_ospeed = B9600;
379 if (ioctl (fileno (TTY_INPUT (tty)), TIOCGETP, &sg) < 0) 382 if (ioctl (fd, TIOCGETP, &sg) < 0)
380 abort (); 383 abort ();
381 emacs_ospeed = sg.sg_ospeed; 384 emacs_ospeed = sg.sg_ospeed;
382#endif /* not HAVE_TERMIO */ 385#endif /* not HAVE_TERMIO */
@@ -392,6 +395,7 @@ init_baud_rate (struct tty_output *tty)
392 baud_rate = 1200; 395 baud_rate = 1200;
393} 396}
394 397
398
395/*ARGSUSED*/ 399/*ARGSUSED*/
396void 400void
397set_exclusive_use (fd) 401set_exclusive_use (fd)
@@ -976,7 +980,7 @@ request_sigio ()
976} 980}
977 981
978void 982void
979unrequest_sigio (struct tty_output *tty) 983unrequest_sigio ()
980{ 984{
981 int off = 0; 985 int off = 0;
982 986
@@ -1078,23 +1082,23 @@ int inherited_pgroup;
1078 group, redirect the TTY to point to our own process group. We need 1082 group, redirect the TTY to point to our own process group. We need
1079 to be in our own process group to receive SIGIO properly. */ 1083 to be in our own process group to receive SIGIO properly. */
1080void 1084void
1081narrow_foreground_group (struct tty_output *tty) 1085narrow_foreground_group (int fd)
1082{ 1086{
1083 int me = getpid (); 1087 int me = getpid ();
1084 1088
1085 setpgrp (0, inherited_pgroup); 1089 setpgrp (0, inherited_pgroup);
1086 /* XXX This only works on the controlling tty. */ 1090 /* XXX This only works on the controlling tty. */
1087 if (inherited_pgroup != me) 1091 if (inherited_pgroup != me)
1088 EMACS_SET_TTY_PGRP (fileno (TTY_INPUT (tty)), &me); 1092 EMACS_SET_TTY_PGRP (fd, &me);
1089 setpgrp (0, me); 1093 setpgrp (0, me);
1090} 1094}
1091 1095
1092/* Set the tty to our original foreground group. */ 1096/* Set the tty to our original foreground group. */
1093void 1097void
1094widen_foreground_group (struct tty_output *tty) 1098widen_foreground_group (int fd)
1095{ 1099{
1096 if (inherited_pgroup != getpid ()) 1100 if (inherited_pgroup != getpid ())
1097 EMACS_SET_TTY_PGRP (fileno (TTY_INPUT (tty)), &inherited_pgroup); 1101 EMACS_SET_TTY_PGRP (fd, &inherited_pgroup);
1098 setpgrp (0, inherited_pgroup); 1102 setpgrp (0, inherited_pgroup);
1099} 1103}
1100 1104
@@ -1289,11 +1293,9 @@ static struct tchars new_tchars = {-1,-1,-1,-1,-1,-1};
1289void 1293void
1290init_all_sys_modes (void) 1294init_all_sys_modes (void)
1291{ 1295{
1292 struct tty_output *tty = tty_list; 1296 struct tty_output *tty;
1293 while (tty) { 1297 for (tty = tty_list; tty; tty = tty->next)
1294 init_sys_modes (tty); 1298 init_sys_modes (tty);
1295 tty = tty->next;
1296 }
1297} 1299}
1298 1300
1299void 1301void
@@ -1358,7 +1360,7 @@ nil means don't delete them until `list-processes' is run. */);
1358 1360
1359#ifdef BSD_PGRPS 1361#ifdef BSD_PGRPS
1360 if (! read_socket_hook && EQ (Vwindow_system, Qnil)) 1362 if (! read_socket_hook && EQ (Vwindow_system, Qnil))
1361 narrow_foreground_group (tty_out); 1363 narrow_foreground_group (fileno (TTY_INPUT (tty_out)));
1362#endif 1364#endif
1363 1365
1364#ifdef HAVE_WINDOW_SYSTEM 1366#ifdef HAVE_WINDOW_SYSTEM
@@ -1683,11 +1685,11 @@ nil means don't delete them until `list-processes' is run. */);
1683 At the time this is called, init_sys_modes has not been done yet. */ 1685 At the time this is called, init_sys_modes has not been done yet. */
1684 1686
1685int 1687int
1686tabs_safe_p (struct tty_output *tty) 1688tabs_safe_p (int fd)
1687{ 1689{
1688 struct emacs_tty etty; 1690 struct emacs_tty etty;
1689 1691
1690 EMACS_GET_TTY (fileno (TTY_INPUT (tty)), &etty); 1692 EMACS_GET_TTY (fd, &etty);
1691 return EMACS_TTY_TABS_OK (&etty); 1693 return EMACS_TTY_TABS_OK (&etty);
1692} 1694}
1693 1695
@@ -1696,9 +1698,7 @@ tabs_safe_p (struct tty_output *tty)
1696 We store 0 if there's no valid information. */ 1698 We store 0 if there's no valid information. */
1697 1699
1698void 1700void
1699get_tty_size (tty_out, widthp, heightp) 1701get_tty_size (int fd, int *widthp, int *heightp)
1700 struct tty_output *tty_out;
1701 int *widthp, *heightp;
1702{ 1702{
1703 1703
1704#ifdef TIOCGWINSZ 1704#ifdef TIOCGWINSZ
@@ -1706,7 +1706,7 @@ get_tty_size (tty_out, widthp, heightp)
1706 /* BSD-style. */ 1706 /* BSD-style. */
1707 struct winsize size; 1707 struct winsize size;
1708 1708
1709 if (ioctl (fileno (TTY_INPUT (tty_out)), TIOCGWINSZ, &size) == -1) 1709 if (ioctl (fd, TIOCGWINSZ, &size) == -1)
1710 *widthp = *heightp = 0; 1710 *widthp = *heightp = 0;
1711 else 1711 else
1712 { 1712 {
@@ -1720,7 +1720,7 @@ get_tty_size (tty_out, widthp, heightp)
1720 /* SunOS - style. */ 1720 /* SunOS - style. */
1721 struct ttysize size; 1721 struct ttysize size;
1722 1722
1723 if (ioctl (fileno (TTY_INPUT (tty_out)), TIOCGSIZE, &size) == -1) 1723 if (ioctl (fd, TIOCGSIZE, &size) == -1)
1724 *widthp = *heightp = 0; 1724 *widthp = *heightp = 0;
1725 else 1725 else
1726 { 1726 {
@@ -1733,7 +1733,7 @@ get_tty_size (tty_out, widthp, heightp)
1733 1733
1734 struct sensemode tty; 1734 struct sensemode tty;
1735 1735
1736 SYS$QIOW (0, fileno (TTY_INPUT (tty_out)), IO$_SENSEMODE, &tty, 0, 0, 1736 SYS$QIOW (0, fd, IO$_SENSEMODE, &tty, 0, 0,
1737 &tty.class, 12, 0, 0, 0, 0); 1737 &tty.class, 12, 0, 0, 0, 0);
1738 *widthp = tty.scr_wid; 1738 *widthp = tty.scr_wid;
1739 *heightp = tty.scr_len; 1739 *heightp = tty.scr_len;
@@ -1793,11 +1793,9 @@ set_window_size (fd, height, width)
1793void 1793void
1794reset_all_sys_modes (void) 1794reset_all_sys_modes (void)
1795{ 1795{
1796 struct tty_output *tty = tty_list; 1796 struct tty_output *tty;
1797 while (tty) { 1797 for (tty = tty_list; tty; tty = tty->next)
1798 reset_sys_modes (tty); 1798 reset_sys_modes (tty);
1799 tty = tty->next;
1800 }
1801} 1799}
1802 1800
1803/* Prepare the terminal for closing it; move the cursor to the 1801/* Prepare the terminal for closing it; move the cursor to the
@@ -1889,7 +1887,7 @@ reset_sys_modes (tty_out)
1889#endif 1887#endif
1890 1888
1891#ifdef BSD_PGRPS 1889#ifdef BSD_PGRPS
1892 widen_foreground_group (tty_out); 1890 widen_foreground_group (fileno (TTY_INPUT (tty_out)));
1893#endif 1891#endif
1894} 1892}
1895 1893