aboutsummaryrefslogtreecommitdiffstats
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorKaroly Lorentey2003-12-31 05:09:29 +0000
committerKaroly Lorentey2003-12-31 05:09:29 +0000
commit819b8f00ed7b8a9a2190efaa02376ed332ecf763 (patch)
treec30ab72204225385c428db008580a9f67f5c215c /src/sysdep.c
parent16c290d8c16fb0fdb574c837c6b1badbc655efe2 (diff)
downloademacs-819b8f00ed7b8a9a2190efaa02376ed332ecf763.tar.gz
emacs-819b8f00ed7b8a9a2190efaa02376ed332ecf763.zip
A few more bugfixes and new features.
(Sigh.) I obviously need to remember to separate individual changes to multiple commits. src/emacsclient.c: Improved error handling. (decode_options): Changed frame option (again) from -f to -t. (print_help_and_exit): Ditto. (copy_from_to): Check EINTR after write, not EAGAIN. Removed SIGIO hack. (pty_conversation): Handle errors transmitted through the socket. Handle pty errors by not reading from it anymore. (main): Restore correct errno after socket_status failed. Send -tty on -t, not -pty. lisp/server.el (server-process-filter): Watch -tty, not -pty. Use make-frame-on-tty instead of make-terminal-frame. Don't set newframe to t if make-frame-on-tty failed. Don't delete frames here. Print correct message when there are no files to edit, but a new frame was requested. (server-sentinel): Delete the frame after the process. (server-handle-delete-frame): New function for delete-frame-functions. (server-start): Add server-handle-delete-frame to delete-frame-functions. (server-buffer-done): Don't delete frames here. src/alloc.c (mark_ttys): Add prototype. (Fgarbage_collect): Call mark_ttys. src/emacs.c: (shut_down_emacs): Don't flush stdout before reset_sys_modes(). src/process.c (add_keyboard_wait_descriptor_called_flag): Removed. (add_keyboard_wait_descriptor): Removed stdin hack. src/sysdep.c: Unconditionally include sysselect.h. (old_fcntl_flags): Changed to an array. (init_sigio, reset_sigio): Use it. (narrow_foreground_group, widen_foreground_group): Use setpgid, not setpgrp. (old_fcntl_owner): Changed to an array. (init_sys_modes, reset_sys_modes): Use it. Fix fsync() and reset_sigio() calls. src/term.c (Qframe_tty_name, Qframe_tty_type): New variables. (syms_of_term): Initialize them. (Fframe_tty_name, Fframe_tty_type): New functions. (term_init): Call add_keyboard_wait_descriptor(). (Fdelete_tty): New function. (delete_tty): Call delete_keyboard_wait_descriptor(). (get_current_tty): Removed. (mark_ttys): New function. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-28
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index 7453be6e3a7..98a671ddbdc 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -45,6 +45,8 @@ extern void srandom P_ ((unsigned int));
45#endif 45#endif
46#endif 46#endif
47 47
48#include "sysselect.h"
49
48#include "blockinput.h" 50#include "blockinput.h"
49#undef NULL 51#undef NULL
50 52
@@ -913,16 +915,15 @@ restore_signal_handlers (saved_handlers)
913 915
914#ifdef F_SETFL 916#ifdef F_SETFL
915 917
916int old_fcntl_flags; 918int old_fcntl_flags[MAXDESC];
917 919
918void 920void
919init_sigio (fd) 921init_sigio (fd)
920 int fd; 922 int fd;
921{ 923{
922#ifdef FASYNC 924#ifdef FASYNC
923 /* XXX What if we get called with more than one fds? */ 925 old_fcntl_flags[fd] = fcntl (fd, F_GETFL, 0) & ~FASYNC;
924 old_fcntl_flags = fcntl (fd, F_GETFL, 0) & ~FASYNC; 926 fcntl (fd, F_SETFL, old_fcntl_flags[fd] | FASYNC);
925 fcntl (fd, F_SETFL, old_fcntl_flags | FASYNC);
926#endif 927#endif
927 interrupts_deferred = 0; 928 interrupts_deferred = 0;
928} 929}
@@ -931,7 +932,7 @@ void
931reset_sigio (fd) 932reset_sigio (fd)
932 int fd; 933 int fd;
933{ 934{
934 fcntl (fd, F_SETFL, old_fcntl_flags); 935 fcntl (fd, F_SETFL, old_fcntl_flags[fd]);
935} 936}
936 937
937#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */ 938#ifdef FASYNC /* F_SETFL does not imply existence of FASYNC */
@@ -1086,11 +1087,12 @@ narrow_foreground_group (int fd)
1086{ 1087{
1087 int me = getpid (); 1088 int me = getpid ();
1088 1089
1089 setpgrp (0, inherited_pgroup); 1090 if (! inherited_pgroup)
1091 inherited_pgroup = getpgid (0);
1090 /* XXX This only works on the controlling tty. */ 1092 /* XXX This only works on the controlling tty. */
1091 if (inherited_pgroup != me) 1093 if (inherited_pgroup != me)
1092 EMACS_SET_TTY_PGRP (fd, &me); 1094 EMACS_SET_TTY_PGRP (fd, &me);
1093 setpgrp (0, me); 1095 setpgid (0, me);
1094} 1096}
1095 1097
1096/* Set the tty to our original foreground group. */ 1098/* Set the tty to our original foreground group. */
@@ -1099,7 +1101,7 @@ widen_foreground_group (int fd)
1099{ 1101{
1100 if (inherited_pgroup != getpid ()) 1102 if (inherited_pgroup != getpid ())
1101 EMACS_SET_TTY_PGRP (fd, &inherited_pgroup); 1103 EMACS_SET_TTY_PGRP (fd, &inherited_pgroup);
1102 setpgrp (0, inherited_pgroup); 1104 setpgid (0, inherited_pgroup);
1103} 1105}
1104 1106
1105#endif /* BSD_PGRPS */ 1107#endif /* BSD_PGRPS */
@@ -1265,7 +1267,7 @@ int lmode;
1265 1267
1266#ifndef F_SETOWN_BUG 1268#ifndef F_SETOWN_BUG
1267#ifdef F_SETOWN 1269#ifdef F_SETOWN
1268int old_fcntl_owner; 1270int old_fcntl_owner[MAXDESC];
1269#endif /* F_SETOWN */ 1271#endif /* F_SETOWN */
1270#endif /* F_SETOWN_BUG */ 1272#endif /* F_SETOWN_BUG */
1271 1273
@@ -1614,7 +1616,8 @@ nil means don't delete them until `list-processes' is run. */);
1614 if (interrupt_input 1616 if (interrupt_input
1615 && ! read_socket_hook && EQ (Vwindow_system, Qnil)) 1617 && ! read_socket_hook && EQ (Vwindow_system, Qnil))
1616 { 1618 {
1617 old_fcntl_owner = fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0); 1619 old_fcntl_owner[fileno (TTY_INPUT (tty_out))] =
1620 fcntl (fileno (TTY_INPUT (tty_out)), F_GETOWN, 0);
1618 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ()); 1621 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, getpid ());
1619 init_sigio (fileno (TTY_INPUT (tty_out))); 1622 init_sigio (fileno (TTY_INPUT (tty_out)));
1620 } 1623 }
@@ -1823,9 +1826,12 @@ reset_sys_modes (tty_out)
1823 ) 1826 )
1824 return; 1827 return;
1825#endif 1828#endif
1829
1826 cmgoto (tty_out, FrameRows (tty_out) - 1, 0); 1830 cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
1827 tty_clear_end_of_line (tty_out, FrameCols (tty_out)); 1831 tty_clear_end_of_line (tty_out, FrameCols (tty_out));
1828 cmgoto (tty_out, FrameRows (tty_out) - 1, 0); 1832 cmgoto (tty_out, FrameRows (tty_out) - 1, 0);
1833 fflush (tty_out->output);
1834
1829#if defined (IBMR2AIX) && defined (AIXHFT) 1835#if defined (IBMR2AIX) && defined (AIXHFT)
1830 { 1836 {
1831 /* HFT devices normally use ^J as a LF/CR. We forced it to 1837 /* HFT devices normally use ^J as a LF/CR. We forced it to
@@ -1842,7 +1848,7 @@ reset_sys_modes (tty_out)
1842#ifdef BSD_SYSTEM 1848#ifdef BSD_SYSTEM
1843#ifndef BSD4_1 1849#ifndef BSD4_1
1844 /* Avoid possible loss of output when changing terminal modes. */ 1850 /* Avoid possible loss of output when changing terminal modes. */
1845 fsync (TTY_OUTPUT (tty_out)); 1851 fsync (fileno (TTY_OUTPUT (tty_out)));
1846#endif 1852#endif
1847#endif 1853#endif
1848 1854
@@ -1851,8 +1857,9 @@ reset_sys_modes (tty_out)
1851#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ 1857#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */
1852 if (interrupt_input) 1858 if (interrupt_input)
1853 { 1859 {
1854 reset_sigio (tty_out); 1860 reset_sigio (fileno (TTY_INPUT (tty_out)));
1855 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN, old_fcntl_owner); 1861 fcntl (fileno (TTY_INPUT (tty_out)), F_SETOWN,
1862 old_fcntl_owner[fileno (TTY_INPUT (tty_out))]);
1856 } 1863 }
1857#endif /* F_SETOWN */ 1864#endif /* F_SETOWN */
1858#endif /* F_SETOWN_BUG */ 1865#endif /* F_SETOWN_BUG */
@@ -1863,7 +1870,7 @@ reset_sys_modes (tty_out)
1863#endif /* F_SETFL */ 1870#endif /* F_SETFL */
1864#ifdef BSD4_1 1871#ifdef BSD4_1
1865 if (interrupt_input) 1872 if (interrupt_input)
1866 reset_sigio (tty_out); 1873 reset_sigio (fileno (TTY_INPUT (tty_out)));
1867#endif /* BSD4_1 */ 1874#endif /* BSD4_1 */
1868 1875
1869 if (tty_out->old_tty) 1876 if (tty_out->old_tty)
@@ -2704,6 +2711,10 @@ read_input_waiting ()
2704 } 2711 }
2705} 2712}
2706 2713
2714#if !defined (HAVE_SELECT) || defined (BROKEN_SELECT_NON_X)
2715#define select sys_select
2716#endif
2717
2707#endif /* not HAVE_SELECT */ 2718#endif /* not HAVE_SELECT */
2708#endif /* not VMS */ 2719#endif /* not VMS */
2709#endif /* not MSDOS */ 2720#endif /* not MSDOS */