X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/89b3af67bb32e691275bf6fa803d1834b2284115..060df5ea7c632b1ac8cc8aac1fb59758165c2084:/bsd/dev/chud/chud_process.c diff --git a/bsd/dev/chud/chud_process.c b/bsd/dev/chud/chud_process.c index a27928e1a..cc82b9890 100644 --- a/bsd/dev/chud/chud_process.c +++ b/bsd/dev/chud/chud_process.c @@ -39,25 +39,28 @@ int chudxnu_current_pid(void); __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 @@ -69,12 +72,13 @@ chudxnu_current_pid(void) 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); } }