Skip to content

fix: handle X11 connection loss gracefully#2140

Merged
jubalh merged 1 commit intomasterfrom
fix/1420
Apr 2, 2026
Merged

fix: handle X11 connection loss gracefully#2140
jubalh merged 1 commit intomasterfrom
fix/1420

Conversation

@jubalh
Copy link
Copy Markdown
Member

@jubalh jubalh commented Mar 31, 2026

Use XSetIOErrorExitHandler on X11 to detect connection loss and disable GTK features (tray, clipboard, notifications).

@jubalh jubalh added this to the 0.18.0 milestone Mar 31, 2026
@jubalh jubalh self-assigned this Mar 31, 2026
@jubalh jubalh mentioned this pull request Mar 31, 2026
@aw32
Copy link
Copy Markdown

aw32 commented Apr 1, 2026

I tested this.
The _x_io_error_handler (which is an io error exit handler) is not called.
Apparently you also need to register an io error handler with XSetIOErrorHandler.
I tried that and then both handlers are called and profanity continues to run.
Thanks for your ongoing work in the niche xmpp ecosystem. ❤️

@jubalh
Copy link
Copy Markdown
Member Author

jubalh commented Apr 1, 2026

I tried that and then both handlers are called and profanity continues to run.

Do you have a patch? :)

@paulfertser
Copy link
Copy Markdown
Contributor

I tried that and then both handlers are called and profanity continues to run.

Do you have a patch? :)

Github doesn't let attach a patch, lol. OK, renamed to .txt.

0001-fix-handle-X11-connection-loss-gracefully.txt

@jubalh
Copy link
Copy Markdown
Member Author

jubalh commented Apr 1, 2026

Thank you for the patch @paulfertser !
I'll additionally add you to Co-authored-by and push the new changes here.

Use XSetIOErrorExitHandler on X11 to detect connection loss and
disable GTK features (tray, clipboard, notifications).

Signed-off-by: Michael Vetter <jubalh@iodoru.org>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Co-authored-by: Paul Fertser <fercerpav@gmail.com>
@jubalh
Copy link
Copy Markdown
Member Author

jubalh commented Apr 1, 2026

I'll wait for your review before merging.

@paulfertser
Copy link
Copy Markdown
Contributor

Passes my testing and LGTM, thank you! :)
A sidenote, if you ever decide to try to re-init Gtk (like to have that tray working after X restart, not sure what would be a meaningful trigger to attempt it though) you'll need to reinstall the handlers after that, also it would be racy (if the server exits again before you had a chance to reinstall handlerls then the whole app crashes).

@jubalh jubalh merged commit dfe7903 into master Apr 2, 2026
9 checks passed
@jubalh jubalh deleted the fix/1420 branch April 2, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants