aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorKaroly Lorentey2003-12-29 07:16:26 +0000
committerKaroly Lorentey2003-12-29 07:16:26 +0000
commit0a1258976b3ac8f6ffc56115def6bd2e5b76f8bc (patch)
tree350c7e580c8d856ec227d350cf396dacac4ce20a /lib-src
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 'lib-src')
-rw-r--r--lib-src/emacsclient.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 0ff8f2e6a3b..51f94877af1 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -102,6 +102,12 @@ char *getcwd ();
102/* Name used to invoke this program. */ 102/* Name used to invoke this program. */
103char *progname; 103char *progname;
104 104
105/* The first argument to main. */
106int main_argc;
107
108/* The second argument to main. */
109char **main_argv;
110
105/* Nonzero means don't wait for a response from Emacs. --no-wait. */ 111/* Nonzero means don't wait for a response from Emacs. --no-wait. */
106int nowait = 0; 112int nowait = 0;
107 113
@@ -294,14 +300,12 @@ xmalloc (size)
294 defined-- exit with an errorcode. 300 defined-- exit with an errorcode.
295*/ 301*/
296void 302void
297fail (argc, argv) 303fail ()
298 int argc;
299 char **argv;
300{ 304{
301 if (alternate_editor) 305 if (alternate_editor)
302 { 306 {
303 int i = optind - 1; 307 int i = optind - 1;
304 execvp (alternate_editor, argv + i); 308 execvp (alternate_editor, main_argv + i);
305 return; 309 return;
306 } 310 }
307 else 311 else
@@ -603,7 +607,7 @@ window_change ()
603#endif /* not SunOS-style */ 607#endif /* not SunOS-style */
604#endif /* not BSD-style */ 608#endif /* not BSD-style */
605 609
606 if (width != 0 && height != 0) 610 if (emacs_pid && width && height)
607 kill (emacs_pid, SIGWINCH); 611 kill (emacs_pid, SIGWINCH);
608} 612}
609 613
@@ -721,7 +725,7 @@ copy_from_to (int in, int out, int sigio)
721 if (r < 0) 725 if (r < 0)
722 return 0; /* Error */ 726 return 0; /* Error */
723 727
724 if (sigio) 728 if (emacs_pid && sigio)
725 { 729 {
726 kill (emacs_pid, SIGIO); 730 kill (emacs_pid, SIGIO);
727 } 731 }
@@ -730,8 +734,10 @@ copy_from_to (int in, int out, int sigio)
730} 734}
731 735
732int 736int
733pty_conversation () 737pty_conversation (FILE *in)
734{ 738{
739 char *str;
740 char string[BUFSIZ];
735 fd_set set; 741 fd_set set;
736 742
737 in_conversation = 1; 743 in_conversation = 1;
@@ -742,6 +748,7 @@ pty_conversation ()
742 FD_ZERO (&set); 748 FD_ZERO (&set);
743 FD_SET (master, &set); 749 FD_SET (master, &set);
744 FD_SET (1, &set); 750 FD_SET (1, &set);
751 FD_SET (fileno (in), &set);
745 res = select (FD_SETSIZE, &set, NULL, NULL, NULL); 752 res = select (FD_SETSIZE, &set, NULL, NULL, NULL);
746 if (res < 0) 753 if (res < 0)
747 { 754 {
@@ -762,6 +769,24 @@ pty_conversation ()
762 if (! copy_from_to (1, master, 1)) 769 if (! copy_from_to (1, master, 1))
763 return 1; 770 return 1;
764 } 771 }
772 if (FD_ISSET (fileno (in), &set))
773 {
774 if (! emacs_pid)
775 {
776 /* Get the pid of the Emacs process.
777 XXX Is there is some nifty libc/kernel feature for doing this?
778 */
779 str = fgets (string, BUFSIZ, in);
780 if (! str)
781 {
782 reset_tty ();
783 fprintf (stderr, "%s: %s\n", progname, str);
784 fail ();
785 }
786
787 emacs_pid = atoi (str);
788 }
789 }
765 } 790 }
766 } 791 }
767 return 1; 792 return 1;
@@ -828,6 +853,8 @@ main (argc, argv)
828 char *cwd, *str; 853 char *cwd, *str;
829 char string[BUFSIZ]; 854 char string[BUFSIZ];
830 855
856 main_argc = argc;
857 main_argv = argv;
831 progname = argv[0]; 858 progname = argv[0];
832 859
833 /* Process options. */ 860 /* Process options. */
@@ -1087,19 +1114,7 @@ To start the server in Emacs, type \"M-x server-start\".\n",
1087 1114
1088 if (here) 1115 if (here)
1089 { 1116 {
1090 /* First of all, get the pid of the Emacs process. 1117 if (! pty_conversation (out))
1091 XXX Is there is some nifty libc/kernel feature for doing this?
1092 */
1093 str = fgets (string, BUFSIZ, in);
1094 emacs_pid = atoi (str);
1095 if (emacs_pid == 0)
1096 {
1097 reset_tty ();
1098 fprintf (stderr, "%s: %s\n", argv[0], str);
1099 fail (argc, argv);
1100 }
1101
1102 if (! pty_conversation ())
1103 { 1118 {
1104 reset_tty (); 1119 reset_tty ();
1105 fprintf (stderr, "%s: ", argv[0]); 1120 fprintf (stderr, "%s: ", argv[0]);