如何通过D-Bus获得systemd oneshot服务的结果

时间:2019-12-13 08:36:53

标签: systemd dbus

我有一个onshot类型的systemd服务,该服务在停止时运行一个进程,例如:

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/my_start_process
ExecStop=/usr/sbin/my_stop_process

二进制my_stop_process始终返回非零退出代码,因此服务无法按预期正确停止,并且查询systemctl status给出Active: failed

当通过D-Bus从另一个应用程序停止服务时,如何获得此失败的结果?

我尝试监视JobRemoved信号,但是它始终包含结果done,这是成功的结果。

signal time=1565928583.772662 sender=:1.0 -> destination=(null destination) serial=554 path=/org/freedesktop/systemd1; interface=org.freedesktop.systemd1.Manager; member=JobRemoved
       uint32 1106
       object path "/org/freedesktop/systemd1/job/1106"
       string "myservice.service"
       string "done"

任何帮助表示赞赏

0 个答案:

没有答案
相关问题