-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sd-bus: action on socket close #15879
Comments
Hmm? this is not how this works. dbus-daemon --user runs as service of systemd --user, and thus remains running as long as the service manager itself. sd-bus actually watches the connection and by default exits the program if gets disconnected (which is controllable with sd_bus_set_close_on_exit()). Hence, I think there must be a misunderstanding somewhere? |
Maybe I'm doing something wrong here, but the docs say sd_bus_set_close_on_exit is enabled per default. I see this when I start a new dbus server, attach my client to it, and kill the dbus server:
When I now kill the dbus server (pid 4568), nothing happens in strace. |
are you sure it connects to the daemon you started there and not the one --user started? |
No, and it was the wrong one. That eval line I used was missing the backticks. But now I am sure, and this looks better:
Ok, so sd-bus notices it. Then I only have missed the way to attach a callback to EPOLLHUP. |
If you want to hook into the disconnection, add a match to the Disconnected signal, as per dbus spec. I guess we can close this again, right? |
Yes, thanks! |
It does not make sense to keep running when we lose connection to one of our dbus connections. systemd/systemd#15879
PS: For future reference: the simplest way to react to a disconnect seems to be to call Docs for sd_bus_set_exit_on_disconnect are not yet at https://www.freedesktop.org/software/systemd/man/sd-bus.html, but already merged in git: https://github.com/systemd/systemd/blob/master/man/sd_bus_set_exit_on_disconnect.xml |
Is your feature request related to a problem? Please describe.
I wrote a small daemon for picking up notifications from system services and displaying them as a desktop notification: systembus-notify
When lingering is enabled, systembus-notify stays running when the user logs out. This kills the user d-bus daemon, but systembus-notify does not notice that the socket gets closed. It only notices when it tries to send the next notification.
Describe the solution you'd like
Unblock
sd_bus_wait()
on socket close and return an error valueDescribe alternatives you've considered
Maybe expose the socket close event somehow to sd-event
The text was updated successfully, but these errors were encountered: