[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/14] proc: turn reap into a normal function
From: |
Justus Winter |
Subject: |
[PATCH 05/14] proc: turn reap into a normal function |
Date: |
Fri, 8 Nov 2013 21:24:13 +0100 |
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
- Re: [PATCH 09/14] proc: fix error handling in S_proc_exception_raise, (continued)
- [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, Justus Winter, 2013/11/08
- Re: [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, Ludovic Courtès, 2013/11/08
- Re: [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, Justus Winter, 2013/11/09
- Re: [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, Richard Braun, 2013/11/09
- Re: [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, Justus Winter, 2013/11/09
- Re: [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, Ludovic Courtès, 2013/11/09
- Re: [PATCH 06/14] proc: turn {init, add}str, compare_versions into normal functions, Samuel Thibault, 2013/11/09
[PATCH 03/14] proc: remove declaration of nested functions from proc.h, Justus Winter, 2013/11/08
[PATCH 05/14] proc: turn reap into a normal function,
Justus Winter <=
[PATCH 08/14] proc: fix a use-after-free error, Justus Winter, 2013/11/08
[PATCH 13/14] mach-defpager: include errno.h, Justus Winter, 2013/11/08
[PATCH 02/14] libtrivfs: improve the out of memory handling in add_el, Justus Winter, 2013/11/08
[PATCH 12/14] mach-defpager: turn dealloc_direct into a normal function, Justus Winter, 2013/11/08
Re: [PATCH 01/14] term: fix error handling in hurdio_mdmctl, Samuel Thibault, 2013/11/09