void
remote_target::remote_detach_1 (inferior *inf, int from_tty)
{
+ REMOTE_SCOPED_DEBUG_ENTER_EXIT;
+
int pid = inferior_ptid.pid ();
struct remote_state *rs = get_remote_state ();
int is_fork_parent;
/* Tell the remote target to detach. */
remote_detach_pid (pid);
+ for (thread_info *thread : inf->threads ())
+ {
+ if (!thread->suspend.waitstatus_pending_p)
+ continue;
+
+ const target_waitstatus &ws = thread->suspend.waitstatus;
+ if (ws.kind != TARGET_WAITKIND_FORKED
+ && ws.kind != TARGET_WAITKIND_VFORKED)
+ continue;
+
+ remote_debug_printf ("Detached thread %s has a pending fork event, "
+ "detaching fork child %d",
+ thread->ptid.to_string ().c_str (),
+ ws.value.related_pid.pid ());
+
+ remote_detach_pid (ws.value.related_pid.pid ());
+ }
+
/* Exit only if this is the only active inferior. */
if (from_tty && !rs->extended && number_of_live_inferiors (this) == 1)
puts_filtered (_("Ending remote debugging.\n"));