diff options
author | obrien <obrien@FreeBSD.org> | 2011-06-14 17:09:30 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2011-06-14 17:09:30 +0000 |
commit | f797e31a8d7ffc81bda219abef89c378821566db (patch) | |
tree | ec2169de1ebd2afc08af998e233233161d6de798 /sys/kern/sys_process.c | |
parent | 0b41fa9638f2db7aece9c1ee748bf6b0e621df18 (diff) | |
download | FreeBSD-src-f797e31a8d7ffc81bda219abef89c378821566db.zip FreeBSD-src-f797e31a8d7ffc81bda219abef89c378821566db.tar.gz |
We should not return ECHILD when debugging a child and the parent does a
"wait4(-1, ..., WNOHANG, ...)". Instead wait(2) should behave as if the
child does not wish to report status at this time.
Reviewed by: jhb
Diffstat (limited to 'sys/kern/sys_process.c')
-rw-r--r-- | sys/kern/sys_process.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index a7f280a..a4c0069 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -831,8 +831,11 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) /* security check done above */ p->p_flag |= P_TRACED; p->p_oppid = p->p_pptr->p_pid; - if (p->p_pptr != td->td_proc) + if (p->p_pptr != td->td_proc) { + /* Remember that a child is being debugged(traced). */ + p->p_pptr->p_dbg_child++; proc_reparent(p, td->td_proc); + } data = SIGSTOP; goto sendsig; /* in PT_CONTINUE below */ @@ -919,11 +922,12 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) PROC_UNLOCK(pp); PROC_LOCK(p); proc_reparent(p, pp); + p->p_pptr->p_dbg_child--; if (pp == initproc) p->p_sigparent = SIGCHLD; } - p->p_flag &= ~(P_TRACED | P_WAITED | P_FOLLOWFORK); p->p_oppid = 0; + p->p_flag &= ~(P_TRACED | P_WAITED | P_FOLLOWFORK); /* should we send SIGCHLD? */ /* childproc_continued(p); */ |