Activation of multiple services provided by the same executable

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Apr 4 07:29:06 PDT 2013


On 04/04/13 12:23, Darren Garvey wrote:
> Why do you need to wait for the busname to appear in your helper
> utility? Rather than using say a "ping" script?

Partly: if the bus name doesn't appear within a reasonable time, the
utility can exit unsuccessfully, informing dbus-daemon that activation
failed; or if activation of the "real name" fails altogether, then
activation of the "alias" should also fail. A fire-and-forget "ping"
can't do that.

(If you're going to activate things with dbus-send, consider using a
StartServiceByName call to the dbus-daemon, rather than sending a Ping
and relying on its side-effect of causing activation: explicit is better
than implicit.)

Partly: we initially wrote mc-wait-for-name for a situation where the
bus name was not directly activatable, but would "naturally" appear as
part of a device's boot/login process (Nokia N900, if I remember
correctly). We could have used /bin/true, but actually waiting for it
seemed less hackish.

(A shell script wrapped around dbus-send also has to start twice as many
processes as just running a binary :-)

> My hope would be that dbus-daemon would see that the "Exec" in the alias
> service file had exited with a zero return code and then wait for a
> RequestName message for the expected bus name. This /appears/ to work
> after some testing, but I'm not convinced.

This does work, but it's not at all clear to me that it should. I don't
think D-Bus services should daemonize, certainly not before they have
their bus name, and I consider this:

>     1341    * In both cases though, just ignore when a process exits
>     with status 0; it's possible for
>     1342    * a program to (misguidedly) "daemonize", and that appears
>     to us as an exit.

to be a pragmatic workaround for faulty services, rather than something
that is meant to work forever.

>     This is not a great solution, and D-Bus would be better off if we could
>     write something [...] analogous to systemd's Alias
>
> I prefer this solution over the other (snipped from below). It's more
> explicit.

If you like this idea, I'd welcome patches via bugs.freedesktop.org (I
don't have a whole lot of time to develop D-Bus right now, so they might
not get reviewed particularly soon, and if you wait for me to implement
it it probably won't happen).

    S


More information about the dbus mailing list