我有一个 .service 用于我不想在启动时启动的进程,而是在给定时间从另一个已经运行的应用程序中以某种方式调用它。
另一种选择是将 D-Bus(我在我的应用程序中使用 glib dbus)服务文件放在/usr/share/dbus-1/services 中,并以某种方式从我的应用程序中调用它。另外,我也无法做到这一点。
假设我的 dbus 服务文件来自 /usr/share/dbus-1/services
是 com.callThis.service
和我的主要服务文件来自 /lib/systemd/system is com.startThis.service
如果我从命令行运行一个简单的内省(introspection):
/home/root # dbus-send --session --type=method_call --print-reply \
--dest=com.callThis /com/callThis org.freedesktop.DBus.Introspectable.Introspect
D-Bus 服务文件将被调用,它将启动 Exec ( com.starThis ) 中的内容。问题是我想使用 D-Bus glib 从 C/C++ 代码中实现这一点。
最佳答案
g_dbus_connection_send_message 的组合与 g_dbus_message_new_method_call或 g_dbus_message_new_signal应该是你要找的。
关于unix - 从 C/C++ 应用程序启动 systemd 服务或调用 D-Bus 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13843093/