How to Listen for SessionRemoved Signal

Lennart Poettering mzqohf at 0pointer.de
Thu Jul 10 13:25:00 PDT 2014


On Thu, 10.07.14 14:34, Kurt von Laven (kurt at endlessm.com) wrote:

> Hello folks,
> 
> I am attempting to listen to the SessionRemoved signal from the login
> manager <http://www.freedesktop.org/wiki/Software/systemd/logind/>. I have
> no trouble in the case where the user logs out and waits for ~15 seconds
> before shutting down, but when the user shuts down the system without first
> logging out I don't hear the SessionRemoved signal in time. I would've
> thought that inhibiting shutdown (by calling the Inhibit method of the
> login manager <http://www.freedesktop.org/wiki/Software/systemd/inhibit/>)
> would be the appropriate way to keep my process alive long enough to record
> the SessionRemoved signal before my process gets killed. Apparently that is
> not the case though. I am fairly certain that I am actually inhibiting
> shutdown, because my process shows up when I call ListInhibitors in D-Feet
> <https://wiki.gnome.org/action/show/Apps/DFeet>. (In case it's relevant,
> I'm using the delay mode.) If anyone has any suggestions on how to debug
> this or knows what I am missing here, that would be greatly appreciated.
> Please let me know if I should be including additional details here;
> apologies in advance as this is my first time posting on this mailing list.

Well, is your code running in the session? If so, then it will never be
able to see the SessionREmoved signal for its own session, because,
well, your process' existance is already enough for the session to
continue to exist.

Also note that some processes (like PulseAudio) tend to stay around for
a while after log-out, this means the session might simply go to
"closing" state then, until PA is done, and only then result in
SessionRemoved.

Also note that if you shutdown the machine via commands that bypass
logind, then logind, your user code and evertyhing else gets abruptly
terminated, so that logind might not be around to send those messages
out.

May I ask what you are trying to do?

This is better discussed on the systemd ML btw...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the dbus mailing list