comparison src/term.c @ 83522:a5d712e6585a

Fix crashes in `delete-terminal' caused by recursive calls or X displays with live frames. * src/termhooks.h (terminal) <deleted>: New member. * src/term.c (delete_tty): Use it. (deleting_tty): Remove old variable. * src/terminal.c (delete_terminal): Use terminal->deleted. * src/xterm.c (x_delete_terminal): Use terminal->deleted. Delete all frames on the display explicitly. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-562
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 20 May 2006 12:20:41 +0000
parents 40a5d8a15056
children b2e7507b55c6
comparison
equal deleted inserted replaced
83521:40a5d8a15056 83522:a5d712e6585a
2968 exit (1); 2968 exit (1);
2969 } 2969 }
2970 2970
2971 2971
2972 2972
2973 static int deleting_tty = 0;
2974
2975
2976 /* Delete the given tty terminal, closing all frames on it. */ 2973 /* Delete the given tty terminal, closing all frames on it. */
2977 2974
2978 static void 2975 static void
2979 delete_tty (struct terminal *terminal) 2976 delete_tty (struct terminal *terminal)
2980 { 2977 {
2981 struct tty_display_info *tty; 2978 struct tty_display_info *tty;
2982 Lisp_Object tail, frame; 2979 Lisp_Object tail, frame;
2983 char *tty_name; 2980 char *tty_name;
2984 int last_terminal; 2981 int last_terminal;
2985 2982
2986 if (deleting_tty) 2983 /* Protect against recursive calls. Fdelete_frame calls us back
2987 /* We get a recursive call when we delete the last frame on this 2984 when we delete our last frame. */
2988 terminal. */ 2985 if (terminal->deleted)
2989 return; 2986 return;
2990 2987
2991 if (terminal->type != output_termcap) 2988 if (terminal->type != output_termcap)
2992 abort (); 2989 abort ();
2993 2990
3020 3017
3021 p->next = tty->next; 3018 p->next = tty->next;
3022 tty->next = 0; 3019 tty->next = 0;
3023 } 3020 }
3024 3021
3025 deleting_tty = 1; 3022 /* We must not throw any errors below this line. */
3023 terminal->deleted = 1;
3026 3024
3027 FOR_EACH_FRAME (tail, frame) 3025 FOR_EACH_FRAME (tail, frame)
3028 { 3026 {
3029 struct frame *f = XFRAME (frame); 3027 struct frame *f = XFRAME (frame);
3030 if (FRAME_TERMCAP_P (f) && FRAME_LIVE_P (f) && FRAME_TTY (f) == tty) 3028 if (FRAME_TERMCAP_P (f) && FRAME_LIVE_P (f) && FRAME_TTY (f) == tty)