1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-23 11:18:54 +00:00
freebsd/bin/ps
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
..
extern.h Include the thread name along with the command name when displaying the 2013-01-18 18:24:40 +00:00
fmt.c - Move 'showthreads' check out of fmt.c. 2013-01-19 00:21:55 +00:00
keyword.c Add support for inspecting process flags set in p_flag2. 2014-06-06 22:52:11 +00:00
Makefile Add -J to filter by matching jail IDs and names. 2014-05-02 15:05:47 +00:00
nlist.c
print.c Don't test arrays for being NULL. 2013-10-21 09:12:04 +00:00
ps.1 Correct the problems with the ptrace(2) making the debuggee an orphan. 2014-08-07 05:47:53 +00:00
ps.c Add -J to filter by matching jail IDs and names. 2014-05-02 15:05:47 +00:00
ps.h