How to detect DBus dying
Tony Houghton
h at realh.co.uk
Thu Sep 29 16:53:23 PDT 2005
In <1128019231.4554.2.camel at localhost.localdomain>, David Eriksson wrote:
> On Thu, 2005-09-29 at 19:05 +0100, Tony Houghton wrote:
>
> > ROX-Session includes, effectively, this bit of code:
> >
> > /* Get notified when the bus dies */
> > local = dbus_g_proxy_new_for_peer(
> > dbus_connection_glib,
> > DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL);
> > g_signal_connect(G_OBJECT(local), "destroy",
> > G_CALLBACK(lost_connection), NULL);
>
> As this uses my own D-BUS C++ bindings you can regard this as
> pseudo-code, but anyway this is how I detect D-BUS 0.23.4 dying:
>
> if (message->Interface() == "org.freedesktop.Local" &&
> message->Member() == "Disconnected")
> {
> error << "Disconnected from D-BUS!!!" << endlog;
> // This should cause the main loop to exit
> kill(getpid(), SIGTERM);
> return DBUS_HANDLER_RESULT_HANDLED;
> }
In other words, don't use the glib stuff, but use a message handler with
the underlying API? I should have thought of that I suppose, because
most of the rest of ROX-Session's dbus code uses the underlying API
anyway. Trouble is, I find most of dbus quite confusing for some
reason, so most of my brain power is taken up just trying to understand
it without enough left for thinking of clever ways of using it :-/.
--
TH * http://www.realh.co.uk
More information about the dbus
mailing list