tags:

views:

34

answers:

1

Hello! Is there a method to inform a process connected via Dbus that the other process died?I mean could the faulty process inform the other one that he had an abnormal termination. I know that you can check the error type return but i want something else. For exemple consider we have a process waiting for an answer but we kill the other process with CTRL+C. Is there a way of notifing the other process..or you should just wait a few seconds for the response...etc

A: 

At a low level: you can connect to the NameOwnerChanged signal on the D-Bus daemon, which is emitted whenever a name is claimed or released on the bus. So if the worker process takes the well-known name com.example.Foo, you can add a match rule for sender=org.freedesktop.DBus,path=/org/freedesktop/DBus,interface=org.freedesktop.DBus,member=NameOwnerChanged,type=signal,arg0=com.example.Foo. (The arg0 part of the match rule prevents you being notified for services other than the one you care about.)

Higher level: if you're waiting on the result of a method call, your binding (such as QDBus or GDBus) should call your callback with an error telling you that this is what happened. But you can also use a higher-level API for watching NameOwnerChanged. For GDBus, see the g_bus_watch family of functions.

wjt