Check whether a dbus caller is still alive

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Sun Oct 1 20:06:37 UTC 2017


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.


More information about the dbus mailing list