Low-level API: dbus_bus_get() + dbus_connection_set_exit_on_disconnect() in a library

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Aug 16 08:52:09 PDT 2011


On Tue, 16 Aug 2011 at 17:10:39 +0200, Michał Górny wrote:
> The case I'm considering is that some application is using
> dbus_bus_get() internally and wants D-Bus to exit on disconnect. If my
> library gets the same connection using dbus_bus_get(), will calling
> dbus_connection_set_exit_on_disconnect(..., FALSE) override
> that application's preference?

Yes. You can safely call it on a connection returned by dbus_bus_get_private(),
but that has the cost that if something else in your application has
connected to the same bus, you're running two parallel connections
(wasting memory).

Are you connecting to the system bus or the session bus?

(One way this could be fixed in a hypothetical D-Bus 2.0 would be for
dbus2_bus_get() to take an explicit boolean exit_on_close parameter - the
application would exit-on-close if at least one of the calls to dbus_bus_get()
had requested exit-on-close behaviour.)

Regards,
    S


More information about the dbus mailing list