diff options
author | jhb <jhb@FreeBSD.org> | 2015-08-01 16:27:52 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2015-08-01 16:27:52 +0000 |
commit | 13db4664b348cae79e3470c70a5d70b51e1f8d86 (patch) | |
tree | 2365ec14ffc0cf77de80a8c9757a3aeed252f54b /sys/kern | |
parent | e83b0ae9f068b68b01e6be4c7f50a3c2a81ee1b2 (diff) | |
download | FreeBSD-src-13db4664b348cae79e3470c70a5d70b51e1f8d86.zip FreeBSD-src-13db4664b348cae79e3470c70a5d70b51e1f8d86.tar.gz |
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.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D2809
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sys_process.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index cb88034..6610960 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -947,7 +947,15 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) } break; case PT_DETACH: - /* reset process parent */ + /* + * Reset the process parent. + * + * NB: This clears P_TRACED before reparenting + * a detached process back to its original + * parent. Otherwise the debugee will be set + * as an orphan of the debugger. + */ + p->p_flag &= ~(P_TRACED | P_WAITED | P_FOLLOWFORK); if (p->p_oppid != p->p_pptr->p_pid) { PROC_LOCK(p->p_pptr); sigqueue_take(p->p_ksi); @@ -963,7 +971,6 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) } else CTR1(KTR_PTRACE, "PT_DETACH: pid %d", p->p_pid); p->p_oppid = 0; - p->p_flag &= ~(P_TRACED | P_WAITED | P_FOLLOWFORK); p->p_stops = 0; /* should we send SIGCHLD? */ |