aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Shahid2018-09-21 11:15:10 -0400
committerEli Zaretskii2018-09-29 09:30:01 +0300
commite8a4d942dd7305b85850603c97d987e52510a726 (patch)
tree0dd2b34be970a561941680a370d98b546b63df51 /src
parent9ad0f1d15c06eb07dfbd9bd3e3b8a0d747942152 (diff)
downloademacs-e8a4d942dd7305b85850603c97d987e52510a726.tar.gz
emacs-e8a4d942dd7305b85850603c97d987e52510a726.zip
Cleanup when opening a new terminal fails. (Bug#32794)
* src/term.c (init_tty): Call delete_terminal_internal if emacs_open fail. * src/terminal.c (delete_terminal): Move some code into delete_terminal_internal and call it. (delete_terminal_internal): New function. * src/termhooks.h: Prototype for delete_terminal_internal.
Diffstat (limited to 'src')
-rw-r--r--src/term.c1
-rw-r--r--src/termhooks.h1
-rw-r--r--src/terminal.c9
3 files changed, 10 insertions, 1 deletions
diff --git a/src/term.c b/src/term.c
index f542fc527c4..8493cc02c4d 100644
--- a/src/term.c
+++ b/src/term.c
@@ -4004,6 +4004,7 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed)
4004 char const *diagnostic 4004 char const *diagnostic
4005 = (fd < 0) ? "Could not open file: %s" : "Not a tty device: %s"; 4005 = (fd < 0) ? "Could not open file: %s" : "Not a tty device: %s";
4006 emacs_close (fd); 4006 emacs_close (fd);
4007 delete_terminal_internal (terminal);
4007 maybe_fatal (must_succeed, terminal, diagnostic, diagnostic, name); 4008 maybe_fatal (must_succeed, terminal, diagnostic, diagnostic, name);
4008 } 4009 }
4009 4010
diff --git a/src/termhooks.h b/src/termhooks.h
index 1b2c95e8248..543809b9e40 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -729,6 +729,7 @@ extern struct terminal *get_named_terminal (const char *);
729extern struct terminal *create_terminal (enum output_method, 729extern struct terminal *create_terminal (enum output_method,
730 struct redisplay_interface *); 730 struct redisplay_interface *);
731extern void delete_terminal (struct terminal *); 731extern void delete_terminal (struct terminal *);
732extern void delete_terminal_internal (struct terminal *);
732extern Lisp_Object terminal_glyph_code (struct terminal *, int); 733extern Lisp_Object terminal_glyph_code (struct terminal *, int);
733 734
734/* The initial terminal device, created by initial_term_init. */ 735/* The initial terminal device, created by initial_term_init. */
diff --git a/src/terminal.c b/src/terminal.c
index 070b8aac1fe..043ee67e0c1 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -314,7 +314,6 @@ create_terminal (enum output_method type, struct redisplay_interface *rif)
314void 314void
315delete_terminal (struct terminal *terminal) 315delete_terminal (struct terminal *terminal)
316{ 316{
317 struct terminal **tp;
318 Lisp_Object tail, frame; 317 Lisp_Object tail, frame;
319 318
320 /* Protect against recursive calls. delete_frame calls the 319 /* Protect against recursive calls. delete_frame calls the
@@ -335,6 +334,14 @@ delete_terminal (struct terminal *terminal)
335 } 334 }
336 } 335 }
337 336
337 delete_terminal_internal (terminal);
338}
339
340void
341delete_terminal_internal (struct terminal *terminal)
342{
343 struct terminal **tp;
344
338 for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal) 345 for (tp = &terminal_list; *tp != terminal; tp = &(*tp)->next_terminal)
339 if (! *tp) 346 if (! *tp)
340 emacs_abort (); 347 emacs_abort ();