]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/dev/chud/chud_process.c
xnu-1504.15.3.tar.gz
[apple/xnu.git] / bsd / dev / chud / chud_process.c
index a27928e1a10256541a97a137e0151f867abf66f3..cc82b9890e91c034f436556f1669b62dbedacc90 100644 (file)
@@ -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);
         }
     }