Android init.rc 在服务退出时触发

发布于 2024-10-18 23:30:08 字数 754 浏览 10 评论 0原文

我能够从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄居者 2024-10-25 23:30:08

阅读源代码我发现 init 在服务退出时将属性 (init.svc.) 设置为“停止”。这意味着您可以使用属性触发器来实现 service-exit-的目的应该做:

service 2nd_svc /system/bin/2nd_svc
    oneshot
    disabled

on property:init.svc.1st_svc=stopped
    start 2nd_svc

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:

service 2nd_svc /system/bin/2nd_svc
    oneshot
    disabled

on property:init.svc.1st_svc=stopped
    start 2nd_svc
-黛色若梦 2024-10-25 23:30:08

从源代码(system/core/init/init.c)来看,此选项已记录但未实现。

Judging from the source code (system/core/init/init.c) this option is documented but not implemented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文