summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--proc/ChangeLog8
-rw-r--r--proc/info.c4
-rw-r--r--proc/msg.c45
-rw-r--r--proc/proc.h1
4 files changed, 40 insertions, 18 deletions
diff --git a/proc/ChangeLog b/proc/ChangeLog
index 9ed123f8..2fa1f662 100644
--- a/proc/ChangeLog
+++ b/proc/ChangeLog
@@ -1,3 +1,11 @@
+1999-05-01 Mark Kettenis <kettenis@gnu.org>
+
+ * msg.c (check_msgport_death): New function.
+ (S_proc_getmsgport): Use it.
+ * proc.h (check_msgport_death): Provide prototype.
+ * info.c (S_proc_getprocinfo): Call check_msgport_death to make
+ sure that our knowledge about P's message port is up to date.
+
1999-05-02 Roland McGrath <roland@baalperazim.frob.com>
* main.c: Include <error.h>.
diff --git a/proc/info.c b/proc/info.c
index c44bde6a..1a398461 100644
--- a/proc/info.c
+++ b/proc/info.c
@@ -376,7 +376,9 @@ S_proc_getprocinfo (struct proc *callerp,
return ESRCH;
task = p->p_task;
- msgport = p->p_deadmsg ? MACH_PORT_NULL : p->p_msgport;
+
+ check_msgport_death (p);
+ msgport = p->p_msgport;
if (*flags & PI_FETCH_THREAD_DETAILS)
*flags |= PI_FETCH_THREADS;
diff --git a/proc/msg.c b/proc/msg.c
index eae1c603..b8413e3b 100644
--- a/proc/msg.c
+++ b/proc/msg.c
@@ -82,6 +82,32 @@ check_message_dying (struct proc *p, struct proc *dyingp)
}
}
+/* Check if the message port of process P has died. Return nonzero if
+ this has indeed happened. */
+int
+check_msgport_death (struct proc *p)
+{
+ /* Only check if the message port passed away, if we know that it
+ was ever alive. */
+ if (p->p_msgport != MACH_PORT_NULL)
+ {
+ mach_port_type_t type;
+ error_t err;
+
+ err = mach_port_type (mach_task_self (), p->p_msgport, &type);
+ if (err || (type & MACH_PORT_TYPE_DEAD_NAME))
+ {
+ /* The port appears to be dead; throw it away. */
+ mach_port_deallocate (mach_task_self (), p->p_msgport);
+ p->p_msgport = MACH_PORT_NULL;
+ p->p_deadmsg = 1;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
error_t
S_proc_getmsgport (struct proc *callerp,
mach_port_t reply_port,
@@ -113,23 +139,8 @@ restart:
if (!p)
return ESRCH;
- /* Only check if the message port passed away, if we know that it
- was ever alive. */
- if (p->p_msgport != MACH_PORT_NULL)
- {
- mach_port_type_t type;
- error_t err;
-
- err = mach_port_type (mach_task_self (), p->p_msgport, &type);
- if (err || (type & MACH_PORT_TYPE_DEAD_NAME))
- {
- /* The port appears to be dead; throw it away. */
- mach_port_deallocate (mach_task_self (), p->p_msgport);
- p->p_msgport = MACH_PORT_NULL;
- p->p_deadmsg = 1;
- goto restart;
- }
- }
+ if (check_msgport_death (p))
+ goto restart;
*msgport = p->p_msgport;
diff --git a/proc/proc.h b/proc/proc.h
index d591b4ea..1190d99e 100644
--- a/proc/proc.h
+++ b/proc/proc.h
@@ -165,6 +165,7 @@ int genpid ();
void abort_getmsgport (struct proc *);
int zombie_check_pid (pid_t);
void check_message_dying (struct proc *, struct proc *);
+int check_msgport_death (struct proc *);
void check_dead_execdata_notify (mach_port_t);
void add_proc_to_hash (struct proc *);