Android init.rc 在服务退出时触发
我能够从 Android 中的 init 脚本 (init.rc) 启动自己的服务,遵循以下位置的指南: http://www.androidenea.com/2009/08/init-process-and-initrc.html 或在 https://android.googlesource.com/platform/system/ core/+/froyo-release/init/readme.txt
有一个名为“on service-exit-<name>”的触发器其中 name 是执行此触发器的操作之前必须退出的服务的名称。 然而,这个触发器似乎不起作用。我启动了一个小型 shell 脚本作为服务,并相应地创建了触发器以启动所有剩余的服务。在执行我的脚本后,init 进程似乎被卡住了,并且不继续执行其余的服务。
最终目标是实现诸如受控或“分阶段”启动过程之类的目标,我可以确保首先执行此脚本,然后启动剩余的服务。我还尝试使用不同的服务类来实现这一点,但失败了
任何关于该主题的帮助都是值得赞赏的。
I was able to start my own services from the init script (init.rc) in Android, following the guides found at: http://www.androidenea.com/2009/08/init-process-and-initrc.html or with the official documentation found at https://android.googlesource.com/platform/system/core/+/froyo-release/init/readme.txt
There is a trigger called "on service-exit-<name>" where name is the name of the service which has to exit before the actions of this trigger are executed.
However, this trigger does not seem to work. I started a small shell script as a service and created the trigger accordingly to start all remaining services afterwards. The init process seems to be stuck after the execution of my script and does not continue with the remaining services.
The final goal would be to achieve something like a controlled or 'staged' boot process, where I can make sure that this script is executed first and then the remainnig services are started. I also tried to accomplish that with using different service classes but failed
Any help on that subject is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
阅读源代码我发现 init 在服务退出时将属性 (init.svc.) 设置为“停止”。这意味着您可以使用属性触发器来实现 service-exit-的目的应该做:
reading the sources i found that init sets a property (init.svc.<name>) to "stopped" when a service exits. this means you can use property triggers to achieve what service-exit-<name> is supposed to do:
从源代码(
system/core/init/init.c
)来看,此选项已记录但未实现。Judging from the source code (
system/core/init/init.c
) this option is documented but not implemented.