+
+ return info;
+}
+
+/* This is a "inferior_exit" observer. Releases the TERMINAL_INFO member
+ of the inferior structure. This field is private to inflow.c, and
+ its type is opaque to the rest of GDB. PID is the target pid of
+ the inferior that is about to be removed from the inferior
+ list. */
+
+static void
+inflow_inferior_exit (struct inferior *inf)
+{
+ struct terminal_info *info;
+
+ info = inferior_data (inf, inflow_inferior_data);
+ if (info != NULL)
+ {
+ xfree (info->run_terminal);
+ xfree (info->ttystate);
+ xfree (info);
+ set_inferior_data (inf, inflow_inferior_data, NULL);
+ }
+}
+
+void
+copy_terminal_info (struct inferior *to, struct inferior *from)
+{
+ struct terminal_info *tinfo_to, *tinfo_from;
+
+ tinfo_to = get_inflow_inferior_data (to);
+ tinfo_from = get_inflow_inferior_data (from);
+
+ xfree (tinfo_to->run_terminal);
+ xfree (tinfo_to->ttystate);
+
+ *tinfo_to = *tinfo_from;
+
+ if (tinfo_from->run_terminal)
+ tinfo_to->run_terminal
+ = xstrdup (tinfo_from->run_terminal);
+
+ if (tinfo_from->ttystate)
+ tinfo_to->ttystate
+ = serial_copy_tty_state (stdin_serial, tinfo_from->ttystate);