3

I need to develop an enterprise application, which should be able to close all other Apps which are currently running via multithreading on non-jailbreaked iOS-devices.

Some years ago I had an App called PKiller or Process Killer, which listed all currently running applications including their program ID and was able to close them. It was an App published in the official AppStore but of course Apple took it down, due to the violation of their guidelines.

Does anybody know how to get currently running processes and shut them down?

(again this App will not go to Apple / the AppStore, due to the fact, that it's an enterprise Application)

EDIT:

I did deeper researches and found out, that you can't even get any running or installed Apps and the connected information like the PID anymore in iOS 9. Apple made the sysctl no longer accessible to sandboxed iOS 9 apps. Also other methods in order to get any third PID failed in iOS 9.

Community
  • 1
  • 1
user3191334
  • 1,148
  • 3
  • 15
  • 33
  • Take a look at the Posix API for getting process info. I am not familiar with them offhand, but you should be able to find APIs to retrieve PIDs and to send signals to them. – Avi Feb 29 '16 at 19:21
  • That would obviously be extremely dangerous. You are basically crashing an app at a random point, for example in the middle of saving files. – gnasher729 Feb 29 '16 at 19:49
  • 1
    Sending a kill signal probably wouldn't be so dangerous, as apps can be terminated by the system at any time anyway. But which processes to kill? I surely wouldn't want to have that app on my own device. – Eiko Feb 29 '16 at 20:03
  • @Eiko iOS terminates app but uses a protocol to let a chance to the app for realizing late operations before... Signaling is seriously more brutal in this model. – Jean-Baptiste Yunès Feb 29 '16 at 20:05
  • Just because the delegate methods (might) get called, that doesn't imply the system isn't killing the processes any differently. – Eiko Feb 29 '16 at 20:10
  • Thanks for the responses! I'll have a look at this API! In my own case, the risk of data loose in other Apps, etc. isn't relevant. – user3191334 Feb 29 '16 at 20:27
  • Glad you found the answer, but ideally you should put the information about sysctl in an answer (you can answer your own question). I just saw your edit after posting my answer, which basically says the same thing. Either way, it's best to keep question / requests for help in the Question and any solutions or answers in an answer to help others who may come later. – wottle Feb 29 '16 at 21:14
  • 1
    You can try and allocate a lot of memory I n order to cause memory pressure to terminate the other apps but apps using background modes may be relaunched. Even in an enterprise App I can't say that what you are trying to do makes any sense to me anyway – Paulw11 Feb 29 '16 at 21:25

2 Answers2

2

I believe you can't do that because apple won't allow you to access the data out side on your application sandbox.

Sandeep Kumar
  • 889
  • 7
  • 24
2

There was a way to do it in the past, but as of iOS 9, it will no longer work. The library that was used for this, sysctl is no longer accessible to sandboxed iOS 9 apps.

In iOS 9, the sandbox now prevents a process from accessing the kern.proc, kern.procargs, and kern.procargs2 values for other processes

and

iOS apps are not permitted to see what other apps are running

https://developer.apple.com/videos/play/wwdc2015-703/

There may be another way, but it certainly will not be as easy as it was a couple of years ago, and not without major effort that Apple will be looking to shut down, even for enterprise apps.

wottle
  • 13,095
  • 4
  • 27
  • 68
  • Yes fortunately I recently found this out too... So if anyone finds another way it's highly appreciated but until then this answer is the best answer. I couldn't find any way, if you don't jailbreak. Thank you for the answer! – user3191334 Feb 29 '16 at 21:18
  • Yes, obviosly jailbreaking will allow this. Without going to the store, you can use things like private APIs, but I think the main way of doing this was through the kernel APIs. Without those, I think you are out of luck. Good luck with what you are trying to do. Are the other apps you are trying to kill internal apps as well. If so, you could pass them a kill command through a custom url scheme. You would just need to change the other apps to be able to handle the scheme and process the request to kill itself using `exit(0);' – wottle Feb 29 '16 at 21:39