Konstantin Belousov d735998057 Correct the problems with the ptrace(2) making the debuggee an orphan.
One problem is inferior(9) looping due to the process tree becoming a
graph instead of tree if the parent is traced by child. Another issue
is due to the use of p_oppid to restore the original parent/child
relationship, because real parent could already exited and its pid
reused (noted by mjg).

Add the function proc_realparent(9), which calculates the parent for
given process. It uses the flag P_TREE_FIRST_ORPHAN to detect the head
element of the p_orphan list and than stepping back to its container
to find the parent process. If the parent has already exited, the
init(8) is returned.

Move the P_ORPHAN and the new helper flag from the p_flag* to new
p_treeflag field of struct proc, which is protected by proctree lock
instead of proc lock, since the orphans relationship is managed under
the proctree_lock already.

The remaining uses of p_oppid in ptrace(PT_DETACH) and process
reapping are replaced by proc_realparent(9).

Phabric:	D417
Reviewed by:	jhb
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2014-08-07 05:47:53 +00:00
..
2014-07-07 00:27:09 +00:00
2014-03-18 21:34:11 +00:00
2014-03-14 06:29:43 +00:00
2014-06-28 17:36:18 +00:00
2012-08-22 20:01:57 +00:00
2012-11-14 10:33:12 +00:00
2014-03-19 12:45:40 +00:00
2014-07-07 00:27:09 +00:00
2014-03-14 06:29:43 +00:00
2014-06-26 13:57:44 +00:00
2014-05-01 22:28:14 +00:00
2012-06-25 05:41:16 +00:00
2014-06-01 04:11:05 +00:00
2014-03-18 21:34:11 +00:00
2014-03-18 21:34:11 +00:00
2012-10-25 09:05:21 +00:00
2014-07-18 14:59:35 +00:00
2014-08-03 22:37:21 +00:00