Created
September 5, 2012 15:30
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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