how get per process info,such as mem,3G flow

331 views Asked by At

I use sysctl () function to get the process list,but I only find start time,name.how can I get more info from per process?

1

There are 1 answers

0
hackerdiehack On

Also see Detect which app is currently running on iOS using sysctl for details. You basically use sysctl again to request more information about a specific PID.

struct kinfo_proc *proc;
int mib[5] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pidNum, 0 };
int count;
size_t size = 0;

// ask the proc size
if(sysctl(mib, 4, NULL, &size, NULL, 0) < 0) return -1;

// allocate memory for proc
proc = (struct kinfo_proc *)malloc(size);

sysctl(mib, 4, proc, &size, NULL, 0);