How to detect DBus dying

David Eriksson twogood at users.sourceforge.net
Thu Sep 29 11:40:31 PDT 2005


On Thu, 2005-09-29 at 19:05 +0100, Tony Houghton wrote:
> I'm trying to update ROX-Session to work with recent versions of DBus
> and I think I found a bug in the glib bindings
> <https://bugs.freedesktop.org/show_bug.cgi?id=4637>, which means I can't
> use dbus_g_proxy_new_for_peer. I'd like to be able to work around the
> problem in ROX-Session so it can be used eg with Ubuntu 5.10 without
> having to replace the dbus packages with a patched version.
> 
> 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);
> 
> Is there a better way to detect DBus dying or can I just replace the
> call with dbus_g_proxy_new_for_name? If so, what should I use as the
> name?
> 
> If I shouldn't be doing this at all I guess it's OK to remove that code
> altogether, because it considers the condition fatal anyway and all
> lost_connection() does is to clear the application's reference to the
> connection and warn the user to restart the X session.

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;
  }


-- 
Regards,
               -\- David Eriksson -/-

        SynCE - http://synce.sourceforge.net
      ScummVM - http://scummvm.sourceforge.net
     Desquirr - http://desquirr.sourceforge.net



More information about the dbus mailing list