Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
515 views
in Technique[技术] by (71.8m points)

cocoa touch - Return a list of running background apps/processes in iOS

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...