summaryrefslogtreecommitdiff
path: root/proc/msg.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-07-20 14:13:55 +0000
committerMiles Bader <miles@gnu.org>1996-07-20 14:13:55 +0000
commit444cff0b5ef810fbafe3e5a4e7ff5e3e455ace5e (patch)
tree7f3434ddad4b4e2f11e7f87a5c9b74c0f39a64fe /proc/msg.c
parentde014a955f2cb75d95ca933773107298e9f5092a (diff)
(S_proc_getmsgport): Deal with PID dying while we're waiting.
Diffstat (limited to 'proc/msg.c')
-rw-r--r--proc/msg.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/proc/msg.c b/proc/msg.c
index be40e1f5..fe173b68 100644
--- a/proc/msg.c
+++ b/proc/msg.c
@@ -96,16 +96,13 @@ S_proc_getmsgport (struct proc *callerp,
pid_t pid,
mach_port_t *msgport)
{
- struct proc *p = pid_find_allow_zombie (pid);
int cancel;
+ struct proc *p = pid_find_allow_zombie (pid);
if (!callerp)
return EOPNOTSUPP;
-
- if (!p)
- return ESRCH;
- while (p->p_deadmsg)
+ while (p && p->p_deadmsg && !p->p_dead)
{
callerp->p_msgportwait = 1;
p->p_checkmsghangs = 1;
@@ -114,8 +111,14 @@ S_proc_getmsgport (struct proc *callerp,
return EOPNOTSUPP;
if (cancel)
return EINTR;
+
+ /* Refetch P in case it went away while we were waiting. */
+ p = pid_find_allow_zombie (pid);
}
+ if (!p)
+ return ESRCH;
+
*msgport = p->p_msgport;
return 0;
}