+ if (ptrace (PT_GET_PROCESS_STATE, pid,
+ (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
+ perror_with_name (("ptrace"));
+
+ switch (pe.pe_report_event)
+ {
+ case PTRACE_FORK:
+ ourstatus->kind = TARGET_WAITKIND_FORKED;
+ ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
+
+ /* Make sure the other end of the fork is stopped too. */
+ fpid = waitpid (pe.pe_other_pid, &status, 0);
+ if (fpid == -1)
+ perror_with_name (("waitpid"));
+
+ if (ptrace (PT_GET_PROCESS_STATE, fpid,
+ (PTRACE_TYPE_ARG3)&pe, sizeof pe) == -1)
+ perror_with_name (("ptrace"));
+
+ gdb_assert (pe.pe_report_event == PTRACE_FORK);
+ gdb_assert (pe.pe_other_pid == pid);
+ if (fpid == ptid_get_pid (inferior_ptid))
+ {
+ ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
+ return pid_to_ptid (fpid);
+ }
+
+ return pid_to_ptid (pid);
+ }
+ }
+#endif
+
+ store_waitstatus (ourstatus, status);
+ return pid_to_ptid (pid);