Does a Systemd Service of Type=dbus timeout if the

2019-08-17 08:21发布

问题:

After a few days of struggle, I realized that my program that waits in a loop inside of main() will timeout after about 15 seconds. I managed to get it to work by creating a task with:

owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
                           "test.mybus",
                           G_BUS_NAME_OWNER_FLAGS_REPLACE,
                           on_bus_acquired,
                           on_name_acquired,
                           on_name_lost,
                           NULL,
                           NULL);

loop = g_main_loop_new (NULL, FALSE);

g_main_loop_run (loop);

My service file (bustest.service) looks like this:

[Unit]
Description=BusTest

[Service]
Type=dbus
ExecStart=/home/user/projects/BusTest
BusName=test.mybus

And the dbus service file:

[D-BUS Service]
Name=test.mybus
Exec=/bin/false
User=root
SystemdService=bustest.service

So it necessary to own the bus name to avoid a timeout? And is it thus necessary to create a separate task that runs g_main_loop_run() if my normal process is a loop?