Check whether a dbus caller is still alive

David Llewellyn-Jones david at
Sun Oct 1 21:28:07 UTC 2017

On 01/10/17 21:06, Lawrence D'Oliveiro wrote:
> On Sun, 1 Oct 2017 14:25:51 +0100, David Llewellyn-Jones wrote:
>> My concern is that the application may get closed before the service
>> responds. Is there any way for the service to check whether the
>> invocation is still valid? If the application closes, I'd like the
>> service to stop the long-running operation.
> You could get the client pid from the request message, and periodically
> check that that process still exists, with kill(pid, 0). The 0 signal
> doesn’t actually try to kill the process, only check that you are able
> to do so; if you get no error or EPERM, then the process still exists,
> but if you get ESRCH, then it is gone.

Thanks for the suggestion. 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?


More information about the dbus mailing list