diff options
Diffstat (limited to 'proc')
-rw-r--r-- | proc/host.c | 3 | ||||
-rw-r--r-- | proc/info.c | 38 | ||||
-rw-r--r-- | proc/notify.c | 5 |
3 files changed, 42 insertions, 4 deletions
diff --git a/proc/host.c b/proc/host.c index 0bf292e2..2b3c4f3c 100644 --- a/proc/host.c +++ b/proc/host.c @@ -474,6 +474,7 @@ S_proc_register_version (pstruct_t server, rebuild_uname (); out: - mach_port_deallocate (mach_task_self (), credential); + if (!err) + mach_port_deallocate (mach_task_self (), credential); return err; } diff --git a/proc/info.c b/proc/info.c index ec072fa5..445fcd8b 100644 --- a/proc/info.c +++ b/proc/info.c @@ -495,6 +495,12 @@ S_proc_getprocinfo (struct proc *callerp, (task_info_t) &pi->taskevents, &tkcount); if (err == MACH_SEND_INVALID_DEST) err = ESRCH; + if (err) + { + /* Something screwy, give up on this bit of info. */ + *flags &= ~PI_FETCH_TASKEVENTS; + err = 0; + } } for (i = 0; i < nthreads; i++) @@ -759,3 +765,35 @@ S_proc_get_tty (struct proc *p, pid_t pid, { return EOPNOTSUPP; /* XXX */ } + +/* Implement proc_getnports as described in <hurd/process.defs>. */ +kern_return_t +S_proc_getnports (struct proc *callerp, + pid_t pid, + mach_msg_type_number_t *nports) +{ + struct proc *p = pid_find (pid); + mach_port_array_t names; + mach_msg_type_number_t ncount; + mach_port_type_array_t types; + mach_msg_type_number_t tcount; + error_t err = 0; + + /* No need to check CALLERP here; we don't use it. */ + + if (!p) + return ESRCH; + + err = mach_port_names (p->p_task, &names, &ncount, &types, &tcount); + if (err == KERN_INVALID_TASK) + err = ESRCH; + + if (!err) { + *nports = ncount; + + munmap (names, ncount * sizeof (mach_port_t)); + munmap (types, tcount * sizeof (mach_port_type_t)); + } + + return err; +} diff --git a/proc/notify.c b/proc/notify.c index 07fc376d..5a112b07 100644 --- a/proc/notify.c +++ b/proc/notify.c @@ -41,12 +41,10 @@ do_mach_notify_dead_name (mach_port_t notify, { struct proc *p; - /* Drop gratuitous extra reference that the notification creates. */ - mach_port_deallocate (mach_task_self (), deadport); - if (notify == generic_port) { check_dead_execdata_notify (deadport); + mach_port_deallocate (mach_task_self (), deadport); return 0; } @@ -59,6 +57,7 @@ do_mach_notify_dead_name (mach_port_t notify, { process_has_exited (p); ports_port_deref (p); + mach_port_deallocate (mach_task_self (), deadport); return 0; } else |