]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/commit
MFC 269656,270024,270443,270993:
authorjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 9 Sep 2015 23:05:52 +0000 (23:05 +0000)
committerjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 9 Sep 2015 23:05:52 +0000 (23:05 +0000)
commit338eec4fd789be731ac8191bffb964ed8463e229
tree5cd9a2dc2938da2e18bf429a66c61c9629281b99
parent612e2f49dc466ea07da2ec65ce1195b6cc349d48
MFC 269656,270024,270443,270993:
Fix problems with orphan handling.  Note that to preserve KBI, p_treeflag
has been added to the end of struct proc and is explicitly zero'd during
fork.

269656:
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).

270024:
Correct the order of arguments passed to LIST_INSERT_AFTER().

270443:
Properly reparent traced processes when the tracer dies.

Previously they were uncoditionally reparented to init. In effect
it was possible that tracee was never returned to original parent.

270993:
Fix up proc_realparent to always return correct process.

Prior to the change it would always return initproc for non-traced
processes.

git-svn-id: svn://svn.freebsd.org/base/stable/9@287603 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
bin/ps/ps.1
sys/kern/kern_exit.c
sys/kern/kern_fork.c
sys/kern/kern_proc.c
sys/kern/sys_process.c
sys/sys/proc.h