diff options
Diffstat (limited to 'proc/info.c')
-rw-r--r-- | proc/info.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/proc/info.c b/proc/info.c index ec072fa5..11625442 100644 --- a/proc/info.c +++ b/proc/info.c @@ -426,7 +426,11 @@ S_proc_getprocinfo (struct proc *callerp, { err = errno; if (*flags & PI_FETCH_THREADS) - munmap (thds, nthreads * sizeof (thread_t)); + { + for (i = 0; i < nthreads; i++) + mach_port_deallocate (mach_task_self (), thds[i]); + munmap (thds, nthreads * sizeof (thread_t)); + } return err; } pi_alloced = 1; @@ -495,6 +499,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 +769,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; +} |