From 444cff0b5ef810fbafe3e5a4e7ff5e3e455ace5e Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Sat, 20 Jul 1996 14:13:55 +0000 Subject: (S_proc_getmsgport): Deal with PID dying while we're waiting. --- proc/msg.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'proc') 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; } -- cgit v1.2.3