Return a list of running background apps/processes in iOS

Make a sysctl API and retrieve the kinfo_proc structure http://fxr.watson.org/fxr/source/sys/kinfo.h?v=DFBSD. 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.*/

Leave a Comment