开发者

Will android kill my daemon which is running as root?

开发者 https://www.devze.com 2023-03-08 14:53 出处:网络
开发者_Go百科I have an app that (has a part that) needs to always run; it\'s not started as a service, the app starts a daemon (written in c) which runs as root.
开发者_Go百科

I have an app that (has a part that) needs to always run; it's not started as a service, the app starts a daemon (written in c) which runs as root.

Is android going to kill it on me to reclaim memory? Does it running as root protect me from this? If not, what can I do to ensure that it never dies and if it does, it starts again?


If your daemon is a pure native application (for example, started through the system's inittab), not something running within the context of an APK, then Android will never kill it. At least, in my situation which is exactly this, the only time my daemon has ever terminated is just prior to my fixing a SIGSEGV ;)


I havent worked with android in awhile now, nor have I worked with root running process. But I do believe that regardless of what user your app is running, android OS might issue it a 'do stop' and then potentially a 'kill' command if memory does get low. The reason I say this is because similar to the full Linux kernel, if it needs memory, it WILL find a way to get it. I have an HTC phone and I have actually seen the kernel kill HTC sense to get RAM, which essentially resets the phone. There are ways to set when an app should be started, I believe you can set hooks that say when an app should be started based off of phone events. Similar to how a txt msg app will start when a phone receives an txt, or how an alarm app will still go off even if you kill the app in a task manager. I believe you can set these in the apps xml config.

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消