Skip to content

Instantly share code, notes, and snippets.

@HungHuynh
Created September 5, 2012 15:30
Show Gist options
  • Save HungHuynh/3638479 to your computer and use it in GitHub Desktop.
Save HungHuynh/3638479 to your computer and use it in GitHub Desktop.
This struct has information about running processes.You can run it in a loop until to get info about all processes. Here is a code snippet- extend it to get info of all processes
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_ALL;
mib[3] = 0;
ret = sysctl(mib, 4, NULL, &size, NULL, 0);
procs = malloc(size);
ret = sysctl(mib, 4, procs, &size, NULL, 0); /* procs is struct kinfo_proc.*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment