__private_extern__ int
chudxnu_pid_for_task(task_t task)
{
- struct proc *p;
+ proc_t p;
+ int pid = -1;
if(task!=TASK_NULL) {
- p = (struct proc *)(get_bsdtask_info(task));
+ p = (proc_t)(get_bsdtask_info(task));
if(p) {
- return (p->p_pid);
+ return (proc_pid(p));
}
}
- return -1;
+ return pid;
}
__private_extern__ task_t
chudxnu_task_for_pid(int pid)
{
- struct proc *p = pfind(pid);
+ task_t t = TASK_NULL;
+ proc_t p = proc_find(pid);
if(p) {
- return p->task;
+ t = p->task;
+ proc_rele(p);
}
- return TASK_NULL;
+ return (t);
}
__private_extern__ int
if(t != TASK_NULL) {
pid = chudxnu_pid_for_task(t);
- } else {
+ }
+ if(-1 == pid) {
// no task, so try looking in the uthread and/or proc
- pid = current_proc()->p_pid;
+ pid = proc_pid(current_proc());
- if(ut && ut->uu_proc) {
- pid = ut->uu_proc->p_pid;
+ if(-1 == pid && ut && ut->uu_proc) {
+ pid = proc_pid(ut->uu_proc);
}
}