Skip to content

Add XIOErrorHandler and make poll() robust against X11 disconnection - #43

Open
jEsuSdA wants to merge 1 commit into
tycho-kirchner:masterfrom
jEsuSdA:fix/xio-error-handler-poll-robustness
Open

Add XIOErrorHandler and make poll() robust against X11 disconnection#43
jEsuSdA wants to merge 1 commit into
tycho-kirchner:masterfrom
jEsuSdA:fix/xio-error-handler-poll-robustness

Conversation

@jEsuSdA

@jEsuSdA jEsuSdA commented Jul 2, 2026

Copy link
Copy Markdown

Summary

Adds an XIOErrorHandler and makes the poll() loop robust against X11 connection errors, fixing silent exits when the X server disconnects.

Problem

Currently, when the X11 connection is lost (e.g. screen lock, VT switch, suspend/resume, or X server crash), fastcompmgr exits silently without any indication of what happened. This makes debugging very difficult — users just see the compositor "disappear".

Additionally, the poll() loop does not handle errors gracefully:

  • POLLHUP/POLLERR/POLLNVAL on the X11 connection fd are ignored
  • EINTR from poll() is not handled, causing the loop to break on signals
  • Other poll errors are silently ignored

Solution

XIOErrorHandler

  • Added xioerror_handler() that prints a clear "X11 connection lost (XIOError)" message to stderr before Xlib exits
  • Registered via XSetIOErrorHandler() in main() right after XSetErrorHandler()

poll() robustness

  • Check ufd.revents for POLLHUP/POLLERR/POLLNVAL and log which condition triggered with a clear fatal message
  • Handle EINTR from poll() correctly: continue the loop instead of breaking
  • Other poll() errors are logged with perror()

Scope

  • Only fastcompmgr.c is touched
  • make clean && make produces zero warnings, zero errors

Impact

Stability/reliability improvement with no functional changes to the compositing logic. Makes diagnosing X11 disconnection issues much easier.

Currently, when the X11 connection is lost (e.g. screen lock, VT switch,
suspend/resume, or X server crash), fastcompmgr exits silently without any
indication of what happened. The poll() loop also does not handle errors
gracefully.

Changes:

- Add an XIOErrorHandler that prints a clear "X11 connection lost" message
to stderr before Xlib exits. This makes debugging much easier when the
compositor disappears unexpectedly.

- Make the poll() loop robust: check for POLLHUP/POLLERR/POLLNVAL on the
X11 connection fd and log which condition triggered. Handle EINTR from
poll() correctly (continue the loop instead of breaking). Log other poll
errors with perror().

This is a stability/reliability improvement with no functional changes to
the compositing logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant