diff --git a/src/process_iterator_apple.c b/src/process_iterator_apple.c index fbeb244..c774e47 100644 --- a/src/process_iterator_apple.c +++ b/src/process_iterator_apple.c @@ -95,38 +95,12 @@ int init_process_iterator(struct process_iterator *it, struct process_filter *fi return 0; } -int get_process_path(int pid, char *pathbuf, size_t buf_size) -{ - int mib[4]; - size_t len; - struct kinfo_proc kp; - - /* Set up the mib array */ - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = pid; - - /* Get process info */ - len = sizeof(kp); - if (sysctl(mib, 4, &kp, &len, NULL, 0) == -1) - { - perror("sysctl"); - return -1; - } - - /* Copy the executable path to pathbuf */ - strncpy(pathbuf, kp.kp_proc.p_comm, buf_size); - - return 0; -} - static void pti2proc(struct proc_taskallinfo *ti, struct process *process) { process->pid = ti->pbsd.pbi_pid; process->ppid = ti->pbsd.pbi_ppid; process->cputime = ti->ptinfo.pti_total_user / 1e6 + ti->ptinfo.pti_total_system / 1e6; - get_process_path(ti->pbsd.pbi_pid, process->command, sizeof(process->command)); + proc_pidpath(ti->pbsd.pbi_pid, process->command, sizeof(process->command)); process->max_cmd_len = sizeof(process->command) - 1; }