summaryrefslogtreecommitdiffstats
path: root/sys/fs/procfs
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-09-09 23:39:30 +0000
committerjhb <jhb@FreeBSD.org>2015-09-09 23:39:30 +0000
commit4a069f68d730aa3275ae62ae00a0be4a5e6e464b (patch)
tree76e5aaf146ac3d3a13836825fb8ac24a7388921a /sys/fs/procfs
parenta7e2ef65e32e8f7cba6dbe0690c663d63c1b4f73 (diff)
downloadFreeBSD-src-4a069f68d730aa3275ae62ae00a0be4a5e6e464b.zip
FreeBSD-src-4a069f68d730aa3275ae62ae00a0be4a5e6e464b.tar.gz
MFC 283281,283282,283562,283647,283836,284000,286158:
Various fixes to orphan handling which also fix issues with following forks. 283281: Always set p_oppid when attaching to an existing process via procfs tracing. This matches the behavior of ptrace(PT_ATTACH). Also, the procfs detach request assumes p_oppid is always set. 283282: Only reparent a traced process to its old parent if the tracing process is not the old parent. Otherwise, proc_reap() will leave the zombie in place resulting in the process' status being returned twice to its parent. Add test cases for PT_TRACE_ME and PT_ATTACH which are fixed by this change. 283562: Do not allow a process to reap an orphan (a child currently being traced by another process such as a debugger). The parent process does need to check for matching orphan pids to avoid returning ECHILD if an orphan has exited, but it should not return the exited status for the child until after the debugger has detached from the orphan process either explicitly or implicitly via wait(). Add two tests for for this case: one where the debugger is the direct child (thus the parent has a non-empty children list) and one where the debugger is not a direct child (so the only "child" of the parent is the orphan). 283647: Tweak the description of when waitpid() doesn't return any status for a non-blocking wait to avoid the word "empty". 283836: Consistently only use one end of the pipe in the parent and debugger processes and do not rely on EOF due to a close() in the debugger. 284000: Add a CHILD_REQUIRE macro similar to ATF_REQUIRE for use in child processes of the main test process. 286158: Clear P_TRACED before reparenting a detached process back to its original parent. Otherwise the debugee will be set as an orphan of the debugger. Add tests for tracing forks via PT_FOLLOW_FORK.
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r--sys/fs/procfs/procfs_ctl.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c
index 5a32863..15679e3 100644
--- a/sys/fs/procfs/procfs_ctl.c
+++ b/sys/fs/procfs/procfs_ctl.c
@@ -143,8 +143,8 @@ procfs_control(struct thread *td, struct proc *p, int op)
p->p_flag |= P_TRACED;
faultin(p);
p->p_xstat = 0; /* XXX ? */
+ p->p_oppid = p->p_pptr->p_pid;
if (p->p_pptr != td->td_proc) {
- p->p_oppid = p->p_pptr->p_pid;
proc_reparent(p, td->td_proc);
}
kern_psignal(p, SIGSTOP);
OpenPOWER on IntegriCloud