【发布时间】:2016-08-08 20:33:23
【问题描述】:
我有一个本机 Android 服务,它由通过 GUI 设置的属性启动和停止。 init.rc中启动和停止服务的命令如下:
service myservice /system/bin/myservice
class late_start
user my_service
disabled
on property:persist.myapp.myservice.enable=1
start myservice
on property:persist.myapp.myservice.enable=0
stop myservice
如果服务停止,有JNI内存资源需要清理,但似乎是通过SIGKILL停止服务:
6944 6974 V myservice: IMyProcessA::onTransact()
712 712 I AP_KERNEL: init: Service 'myservice' is being killed...
510 510 I ServiceManager: service 'ProcessA.MyService' died
656 656 V ProcessA: ProcessA::NotificationClient::binderDied()
656 656 V ProcessA: removeNotificationClient() 0xb6bc60a8, pid 6944
656 656 V ProcessA: ProcessA::NotificationClient::~NotificationClient()
712 712 I AP_KERNEL: init: Service 'myservice' (pid 6944) killed by signal 9
712 712 I AP_KERNEL: init: Service 'myservice' (pid 6944) killing any children in process group
由于无法拦截 SIGKILL 进行清理,是否有任何用于 init.rc 'stop myservice' 的选项可以将终止信号更改为我可以拦截的信号,例如 SIGTERM?
【问题讨论】:
标签: android linux service signals init