diff options
author | Thomas Bushnell <thomas@gnu.org> | 1999-05-04 17:05:27 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1999-05-04 17:05:27 +0000 |
commit | 0f07be8955c4febfd2662e222f0371c8a92ae1d2 (patch) | |
tree | ef01b3aedfa5265ef882c7e2eeab0289278b3b1e /proc/msg.c | |
parent | d7929458f96268c914dcf886e8fae5fa2ba00a3a (diff) |
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.
Diffstat (limited to 'proc/msg.c')
-rw-r--r-- | proc/msg.c | 45 |
1 files changed, 28 insertions, 17 deletions
@@ -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; |