aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorKaroly Lorentey2003-12-29 07:16:26 +0000
committerKaroly Lorentey2003-12-29 07:16:26 +0000
commit0a1258976b3ac8f6ffc56115def6bd2e5b76f8bc (patch)
tree350c7e580c8d856ec227d350cf396dacac4ce20a /src/sysdep.c
parent04c3243c2a25812c6d0a324d29b8fd1d5acaa715 (diff)
downloademacs-0a1258976b3ac8f6ffc56115def6bd2e5b76f8bc.tar.gz
emacs-0a1258976b3ac8f6ffc56115def6bd2e5b76f8bc.zip
Bugfix festival.
lib-src/emacsclient.c (main_argc, main_argv): New variables. (main): Initialize them. (fail): Use them. (window_change, copy_from_to): Don't kill if emacs_pid is zero. (pty_conversation): Watch the command socket, too. Read emacs_pid here. Emacs and emacsclient could deadlock if Emacs tried to do a reset_sys_modes before sending its pid. lisp/server.el: Automatically delete the client frame when done editing. (server-frames): New variable. (server-process-filter, server-sentinel, server-buffer-done): Use it. (server-process-filter): Do a redisplay before evaluating other parameters. (Prevents "emacsclient -h -e '(delete-frame)'" from messing up the system. src/dispextern.h: Update prototypes. src/dispnew.c (window_change_signal): Do nothing if !term_initted. (init_display): Set the frame size from the tty data after term_init. src/emacs.c (main): Make sure things that init_sys_modes needs are initialized before init_display (which calls init_sys_modes now). (sort_args): Use xfree, not free. (shut_down_emacs) [!EMACS_HAVE_TTY_PGRP]: Use reset_all_sys_modes instead of reset_sys_modes. src/frame.c (make_terminal_frame): Sigh. Move terminal initialization back to the middle of frame setup. Handle errors by making sure that the delete_tty() called from term_init() will see and delete this frame. (Fdelete_frame): Kill the frame before calling delete_tty(). Fix condition for tty deletion. src/keyboard.c (Fset_input_mode): Use reset_sys_modes on the current terminal only. src/lisp.h: Remove duplicate prototypes. src/msdos.c (croak): use reset_all_sys_modes(). src/sysdeps.c (init_baud_rate): Added tty parameter, use it instead of CURTTY. (child_setup_tty): Reset sigio on stdin, not CURTTY(). (reset_sigio): Added fd parameter, put explicit fcntl there. (request_sigio, unrequest_sigio)[FASYNC]: Simply block/unblock the SIGIO signal, don't touch the file params. There are multiple ttys now, and we can't disable the SIGIO from emacsclient. (get_tty_size)[VMS]: Use tty_out instead of CURTTY(). (reset_sys_modes): Don't call cursor_to, clear_end_of_line; call cmgoto and tty_clear_end_of_line instead. The frame may already be dead. Updated reset_sigio call. src/term.c (clear_and_of_line): Separate tty-dependent stuff to tty_clear_end_of_line() for reset_sys_modes. (tty_clear_end_of_line): New function. (term_init): Added frame parameter, don't use selected_frame. Set the frame's output_data.tty value (in case there is an error later). Set the frame size in Wcm, not in the frame. Only free the termcap buffer if there is a termcap-related error. Call init_sys_modes last, not first. (deleting_tty): New variable. (delete_tty): Use it for handling recursive calls. Free deleted tty, except its Wcm (there is still a dangling reference somewhere). git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-19
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c67
1 files changed, 35 insertions, 32 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index ad8b5c518b1..81299b37516 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -184,6 +184,7 @@ extern int quit_char;
184#include "termopts.h" 184#include "termopts.h"
185#include "dispextern.h" 185#include "dispextern.h"
186#include "process.h" 186#include "process.h"
187#include "cm.h" /* for reset_sys_modes */
187 188
188#ifdef WINDOWSNT 189#ifdef WINDOWSNT
189#include <direct.h> 190#include <direct.h>
@@ -330,7 +331,7 @@ stuff_char (char c)
330#endif /* SIGTSTP */ 331#endif /* SIGTSTP */
331 332
332void 333void
333init_baud_rate () 334init_baud_rate (struct tty_output *tty)
334{ 335{
335 if (noninteractive) 336 if (noninteractive)
336 emacs_ospeed = 0; 337 emacs_ospeed = 0;
@@ -345,7 +346,7 @@ init_baud_rate ()
345#ifdef VMS 346#ifdef VMS
346 struct sensemode sg; 347 struct sensemode sg;
347 348
348 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_SENSEMODE, &sg, 0, 0, 349 SYS$QIOW (0, fileno (TTY_INPUT (tty)), IO$_SENSEMODE, &sg, 0, 0,
349 &sg.class, 12, 0, 0, 0, 0 ); 350 &sg.class, 12, 0, 0, 0, 0 );
350 emacs_ospeed = sg.xmit_baud; 351 emacs_ospeed = sg.xmit_baud;
351#else /* not VMS */ 352#else /* not VMS */
@@ -353,7 +354,7 @@ init_baud_rate ()
353 struct termios sg; 354 struct termios sg;
354 355
355 sg.c_cflag = B9600; 356 sg.c_cflag = B9600;
356 tcgetattr (fileno (TTY_INPUT (CURTTY())), &sg); 357 tcgetattr (fileno (TTY_INPUT (tty)), &sg);
357 emacs_ospeed = cfgetospeed (&sg); 358 emacs_ospeed = cfgetospeed (&sg);
358#if defined (USE_GETOBAUD) && defined (getobaud) 359#if defined (USE_GETOBAUD) && defined (getobaud)
359 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */ 360 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */
@@ -366,16 +367,16 @@ init_baud_rate ()
366 367
367 sg.c_cflag = B9600; 368 sg.c_cflag = B9600;
368#ifdef HAVE_TCATTR 369#ifdef HAVE_TCATTR
369 tcgetattr (fileno (TTY_INPUT (CURTTY())), &sg); 370 tcgetattr (fileno (TTY_INPUT (tty)), &sg);
370#else 371#else
371 ioctl (fileno (TTY_INPUT (CURTTY())), TCGETA, &sg); 372 ioctl (fileno (TTY_INPUT (tty)), TCGETA, &sg);
372#endif 373#endif
373 emacs_ospeed = sg.c_cflag & CBAUD; 374 emacs_ospeed = sg.c_cflag & CBAUD;
374#else /* neither VMS nor TERMIOS nor TERMIO */ 375#else /* neither VMS nor TERMIOS nor TERMIO */
375 struct sgttyb sg; 376 struct sgttyb sg;
376 377
377 sg.sg_ospeed = B9600; 378 sg.sg_ospeed = B9600;
378 if (ioctl (fileno (TTY_INPUT (CURTTY())), TIOCGETP, &sg) < 0) 379 if (ioctl (fileno (TTY_INPUT (tty)), TIOCGETP, &sg) < 0)
379 abort (); 380 abort ();
380 emacs_ospeed = sg.sg_ospeed; 381 emacs_ospeed = sg.sg_ospeed;
381#endif /* not HAVE_TERMIO */ 382#endif /* not HAVE_TERMIO */
@@ -649,7 +650,7 @@ child_setup_tty (out)
649 650
650#ifdef BSD4_1 651#ifdef BSD4_1
651 if (interrupt_input) 652 if (interrupt_input)
652 reset_sigio (); 653 reset_sigio (0);
653#endif /* BSD4_1 */ 654#endif /* BSD4_1 */
654#ifdef RTU 655#ifdef RTU
655 { 656 {
@@ -915,6 +916,7 @@ init_sigio (fd)
915 int fd; 916 int fd;
916{ 917{
917#ifdef FASYNC 918#ifdef FASYNC
919 /* XXX What if we get called with more than one fds? */
918 old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC; 920 old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC;
919 fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC); 921 fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC);
920#endif 922#endif
@@ -922,9 +924,10 @@ init_sigio (fd)
922} 924}
923 925
924void 926void
925reset_sigio () 927reset_sigio (fd)
928 int fd;
926{ 929{
927 unrequest_sigio (); 930 fcntl (fd, F_SETFL, old_fcntl_flags);
928} 931}
929 932
930#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ 933#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
@@ -938,13 +941,13 @@ request_sigio ()
938#ifdef SIGWINCH 941#ifdef SIGWINCH
939 sigunblock (sigmask (SIGWINCH)); 942 sigunblock (sigmask (SIGWINCH));
940#endif 943#endif
941 fcntl (fileno (TTY_INPUT (CURTTY())), F_SETFL, old_fcntl_flags | FASYNC); 944 sigunblock (sigmask (SIGIO));
942 945
943 interrupts_deferred = 0; 946 interrupts_deferred = 0;
944} 947}
945 948
946void 949void
947unrequest_sigio () 950unrequest_sigio (void)
948{ 951{
949 if (read_socket_hook) 952 if (read_socket_hook)
950 return; 953 return;
@@ -952,7 +955,7 @@ unrequest_sigio ()
952#ifdef SIGWINCH 955#ifdef SIGWINCH
953 sigblock (sigmask (SIGWINCH)); 956 sigblock (sigmask (SIGWINCH));
954#endif 957#endif
955 fcntl (fileno (TTY_INPUT (CURTTY())), F_SETFL, old_fcntl_flags); 958 sigblock (sigmask (SIGIO));
956 interrupts_deferred = 1; 959 interrupts_deferred = 1;
957} 960}
958 961
@@ -967,19 +970,21 @@ request_sigio ()
967 if (read_socket_hook) 970 if (read_socket_hook)
968 return; 971 return;
969 972
970 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &on); 973 /* XXX CURTTY() is bogus here. */
974 ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &on);
971 interrupts_deferred = 0; 975 interrupts_deferred = 0;
972} 976}
973 977
974void 978void
975unrequest_sigio () 979unrequest_sigio (struct tty_output *tty)
976{ 980{
977 int off = 0; 981 int off = 0;
978 982
979 if (read_socket_hook) 983 if (read_socket_hook)
980 return; 984 return;
981 985
982 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &off); 986 /* XXX CURTTY() is bogus here. */
987 ioctl (fileno (TTY_INPUT (CURTTY ())), FIOASYNC, &off);
983 interrupts_deferred = 1; 988 interrupts_deferred = 1;
984} 989}
985 990
@@ -1000,7 +1005,7 @@ request_sigio ()
1000 1005
1001 sigemptyset (&st); 1006 sigemptyset (&st);
1002 sigaddset (&st, SIGIO); 1007 sigaddset (&st, SIGIO);
1003 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &on); 1008 ioctl (0, FIOASYNC, &on); /* XXX This fails for multiple ttys. */
1004 interrupts_deferred = 0; 1009 interrupts_deferred = 0;
1005 sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0); 1010 sigprocmask (SIG_UNBLOCK, &st, (sigset_t *)0);
1006} 1011}
@@ -1013,7 +1018,7 @@ unrequest_sigio ()
1013 if (read_socket_hook) 1018 if (read_socket_hook)
1014 return; 1019 return;
1015 1020
1016 ioctl (fileno (TTY_INPUT (CURTTY())), FIOASYNC, &off); 1021 ioctl (0, FIOASYNC, &off); /* XXX This fails for multiple ttys. */
1017 interrupts_deferred = 1; 1022 interrupts_deferred = 1;
1018} 1023}
1019 1024
@@ -1728,7 +1733,7 @@ get_tty_size (tty_out, widthp, heightp)
1728 1733
1729 struct sensemode tty; 1734 struct sensemode tty;
1730 1735
1731 SYS$QIOW (0, fileno (TTY_INPUT (CURTTY())), IO$_SENSEMODE, &tty, 0, 0, 1736 SYS$QIOW (0, fileno (TTY_INPUT (tty_out)), IO$_SENSEMODE, &tty, 0, 0,
1732 &tty.class, 12, 0, 0, 0, 0); 1737 &tty.class, 12, 0, 0, 0, 0);
1733 *widthp = tty.scr_wid; 1738 *widthp = tty.scr_wid;
1734 *heightp = tty.scr_len; 1739 *heightp = tty.scr_len;
@@ -1795,14 +1800,12 @@ reset_all_sys_modes (void)
1795 } 1800 }
1796} 1801}
1797 1802
1798/* Prepare the terminal for exiting Emacs; move the cursor to the 1803/* Prepare the terminal for closing it; move the cursor to the
1799 bottom of the frame, turn off interrupt-driven I/O, etc. */ 1804 bottom of the frame, turn off interrupt-driven I/O, etc. */
1800void 1805void
1801reset_sys_modes (tty_out) 1806reset_sys_modes (tty_out)
1802 struct tty_output *tty_out; 1807 struct tty_output *tty_out;
1803{ 1808{
1804 struct frame *sf;
1805
1806 if (noninteractive) 1809 if (noninteractive)
1807 { 1810 {
1808 fflush (stdout); 1811 fflush (stdout);
@@ -1822,11 +1825,9 @@ reset_sys_modes (tty_out)
1822 ) 1825 )
1823 return; 1826 return;
1824#endif 1827#endif
1825 sf = SELECTED_FRAME (); 1828 cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
1826 cursor_to (FRAME_LINES (sf) - 1, 0); 1829 tty_clear_end_of_line (tty_out, FrameCols (tty_out));
1827 clear_end_of_line (FRAME_COLS (sf)); 1830 cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
1828 /* clear_end_of_line may move the cursor */
1829 cursor_to (FRAME_LINES (sf) - 1, 0);
1830#if defined (IBMR2AIX) && defined (AIXHFT) 1831#if defined (IBMR2AIX) && defined (AIXHFT)
1831 { 1832 {
1832 /* HFT devices normally use ^J as a LF/CR. We forced it to 1833 /* HFT devices normally use ^J as a LF/CR. We forced it to
@@ -1852,7 +1853,7 @@ reset_sys_modes (tty_out)
1852#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ 1853#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */
1853 if (interrupt_input) 1854 if (interrupt_input)
1854 { 1855 {
1855 reset_sigio (); 1856 reset_sigio (tty_out);
1856 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, old_fcntl_owner); 1857 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, old_fcntl_owner);
1857 } 1858 }
1858#endif /* F_SETOWN */ 1859#endif /* F_SETOWN */
@@ -1864,7 +1865,7 @@ reset_sys_modes (tty_out)
1864#endif /* F_SETFL */ 1865#endif /* F_SETFL */
1865#ifdef BSD4_1 1866#ifdef BSD4_1
1866 if (interrupt_input) 1867 if (interrupt_input)
1867 reset_sigio (); 1868 reset_sigio (tty_out);
1868#endif /* BSD4_1 */ 1869#endif /* BSD4_1 */
1869 1870
1870 if (tty_out->old_tty) 1871 if (tty_out->old_tty)
@@ -2170,7 +2171,8 @@ init_sigio (fd)
2170 request_sigio (); 2171 request_sigio ();
2171} 2172}
2172 2173
2173reset_sigio () 2174reset_sigio (fd)
2175 int fd;
2174{ 2176{
2175 unrequest_sigio (); 2177 unrequest_sigio ();
2176} 2178}
@@ -2720,12 +2722,13 @@ init_sigio (fd)
2720} 2722}
2721 2723
2722void 2724void
2723reset_sigio () 2725reset_sigio (fd)
2726 int fd;
2724{ 2727{
2725 if (noninteractive) 2728 if (noninteractive)
2726 return; 2729 return;
2727 lmode = ~LINTRUP & lmode; 2730 lmode = ~LINTRUP & lmode;
2728 ioctl (0, TIOCLSET, &lmode); 2731 ioctl (fd, TIOCLSET, &lmode);
2729} 2732}
2730 2733
2731void 2734void
@@ -3173,7 +3176,7 @@ sys_getenv (name)
3173#undef abort 3176#undef abort
3174sys_abort () 3177sys_abort ()
3175{ 3178{
3176 reset_sys_modes (); 3179 reset_all_sys_modes ();
3177 LIB$SIGNAL (SS$_DEBUG); 3180 LIB$SIGNAL (SS$_DEBUG);
3178} 3181}
3179#endif /* abort */ 3182#endif /* abort */