Return a list of running background apps/processes in iOS

只愿长相守 提交于 2019-12-28 02:13:11

问题


I'm working on a jailbreak app, and want to send SIGKILL messages to specific apps that may be running on a user's device (with their permission, of course).

Google is not turning up anything for me. Is there a plist or array that keeps track of running processes?

Thanks for any help you all can give, you're wonderful!


回答1:


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.*/


来源:https://stackoverflow.com/questions/5906180/return-a-list-of-running-background-apps-processes-in-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!