Check whether a dbus caller is still alive
David Llewellyn-Jones
david at flypig.co.uk
Mon Oct 2 08:01:23 UTC 2017
On 02/10/17 01:03, Lawrence D'Oliveiro wrote:
> On Sun, 1 Oct 2017 22:28:07 +0100, David Llewellyn-Jones wrote:
>
>> When you say 'get the client pid from the
>> request message', do you mean get the client to send its pid as a
>> parameter, or is there a way to extract the pid from the request?
>
> OK, I misremembered how it actually works. You can get the sender
> unique name from the message. Then ask the D-Bus daemon itself for the
> process ID corresponding to this name, with the
> GetConnectionUnixProcessID method request
> <https://dbus.freedesktop.org/doc/dbus-specification.html>.
>
> You can do the latter just once per request, then save the process ID
> with your context for servicing that request and poll it periodically as
> I described.
Thank you Lawrence. It looks like I now have a solution which is
slightly different: listening for a "NameOwnerChange" signal with the
sender unique name of the message changing to "", as suggested by Thiago.
However, it was your reply above which solved it for me, by suggesting
to "get the sender unique name from the message". I'd been trying to get
the name from the *connection*, when I should have been focussing on the
*message*.
So, many thanks for your help: much appreciated.
David
--
Website: http://www.flypig.co.uk
More information about the dbus
mailing list