com.test.hello.service,安装到dbus系统目录下
[D-BUS Service]
Name=com.test.hello
Exec=/bin/false
SystemdService=hello.service
hello.service,安装到systemd下
[Unit]
Description=hello
[Service]
Type=dbus
BusName=com.test.hello
ExecStart=/usr/bin/hello
Restart=on-failure
SuccessExitStatus=0 38
[Install]
WantedBy=multi-user.target
client调用代码
bool request_to_server()
{
GError *gerror = NULL;
GDBusProxy *bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
"com.test.hello",
"/com/test/hello",
"com.test.hello",
NULL,
&gerror);
if (NULL == bproxy) {
printf ("g_bus_get_sync Failed [%s]", gerror ? gerror->message : NULL);
return