Stopping the d-bus daemon when the last connection closes

Thomas Sondergaard ts at medical-insight.com
Tue Aug 23 02:10:05 PDT 2011


Thiago Macieira wrote:
> On Tuesday, 23 de August de 2011 10:10:15 Thomas Sondergaard wrote:
>> I wrote a message to the mailing list a few weeks ago about getting the
>> dbus-daemon to exit when the last client disconnects, but I didn't get
>> an answer. Not sure if the tone in my message was impolite, or the
>> request stupid, but I thought I'd try again.
> 
> I don't remember seeing it, but now that I look for it, I can see it.
> 
> Auto-exit-on-last-disconnect is also one of the things I mentioned in the 
> Desktop Summit, except I called it "suicide mode".
> 
>> I have an MS-Windows application (originally born on Linux) that uses
>> D-bus for communication between processes. On Windows the default
>> autolaunch: address causes a dbus-daemon to be created that is shared
>> with the desktop-session. This means a useful bus pops into existence
>> the first time you need it - very nice. Now, when my application is
>> closed by the user all my processes go away, but the dbus-daemon.exe
>> lingers. I'd like it to go away when the last client disconnects or
>> briefly after.
>>
>> Is there a way to get that behaviour now? I imagine this would be useful
>>   on Windows in general.
> 
> It's possible to get it, even on Linux. But it needs to be done very carefully 
> to avoid race conditions: what if an application decides to start at the very 
> moment that the bus decides to exit?

Is there a use for it on Linux? If I remember correctly, you get a 
private dbus-daemon on Linux if DBUS_SESSION_BUS_ADDRESS (from memory) 
is not set. On Windows the default behaviour (autolaunch:) is to create 
a bus that is shared, and the creation of that bus is protected with a 
mutex to avoid races on construction. The same mutex is used on 
destruction I assume and I further assume that that would make it 
relatively easy to implement a suicide mode.

Any input from the Windows devs/maintainers?

Regards,

Thomas



More information about the dbus mailing list