Previously reap was a nested function defined inside of S_proc_wait. * proc/wait.c: Turn reap into a normal function. --- proc/wait.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-)
diff --git a/proc/wait.c b/proc/wait.c index 824e667..f70dfe9 100644 --- a/proc/wait.c +++ b/proc/wait.c @@ -159,6 +159,30 @@ alert_parent (struct proc *p) } } +static int +reap (struct proc *child, + int options, + int *status, + int *sigcode, + struct rusage *ru, + pid_t *pid_status) +{ + if (child->p_waited + || (!child->p_dead + && (!child->p_stopped + || !(child->p_traced || (options & WUNTRACED))))) + return 0; + child->p_waited = 1; + *status = child->p_status; + *sigcode = child->p_sigcode; + *ru = child->p_rusage; /* all zeros if !p_dead */ + *pid_status = child->p_pid; + if (child->p_dead) + complete_exit (child); + return 1; +} + + kern_return_t S_proc_wait (struct proc *p, mach_port_t reply_port, @@ -172,23 +196,6 @@ S_proc_wait (struct proc *p, { int cancel; - int reap (struct proc *child) - { - if (child->p_waited - || (!child->p_dead - && (!child->p_stopped - || !(child->p_traced || (options & WUNTRACED))))) - return 0; - child->p_waited = 1; - *status = child->p_status; - *sigcode = child->p_sigcode; - *ru = child->p_rusage; /* all zeros if !p_dead */ - *pid_status = child->p_pid; - if (child->p_dead) - complete_exit (child); - return 1; - } - if (!p) return EOPNOTSUPP; @@ -203,7 +210,7 @@ S_proc_wait (struct proc *p, struct proc *child = pid_find_allow_zombie (pid); if (!child || child->p_parent != p) return ECHILD; - if (reap (child)) + if (reap (child, options, status, sigcode, ru, pid_status)) return 0; } else @@ -215,7 +222,7 @@ S_proc_wait (struct proc *p, if (waiter_cares (pid, p->p_pgrp->pg_pgid, child->p_pid, child->p_pgrp->pg_pgid)) { - if (reap (child)) + if (reap (child, options, status, sigcode, ru, pid_status)) return 0; had_a_match = 1; } -- 1.7.10.4