-
-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Description
Background
On Linux/X11, clipboard.Init() establishes the X11 connection. When it fails (e.g. missing DISPLAY or no X server), subsequent calls to clipboard.Write keep blocking for ~5 seconds before returning the same error. Additionally, some distros/containers only ship libx11.so.6, so attempting to load the unversioned libX11.so fails and the package cannot start.
Steps to Reproduce
Write waits 5s after Init failure
- Run on Linux without X11 (unset
DISPLAYor use a headless container). - Call
clipboard.Init(); it returns an error likefailed to open display. - Immediately call
clipboard.Write(clipboard.FmtText, []byte("test")). - The call blocks for ~5 seconds before returning, even though Init already failed.
Missing libX11.so on systems with only libx11.so.6
- Build/run any program using this package on a system that only exposes
libx11.so.6. - The program panics during initialization because
dlopen("libX11.so")fails.
Actual Behavior
clipboard.Writewaits the full timeout when Init already reported an error.- Systems without the unversioned
libX11.socannot load the package at all.
Expected Behavior
- Once Init fails, subsequent write/watch calls should immediately return the same error instead of waiting.
- The loader should fall back to
libx11.so.6so common distros/containers work out of the box.
Proposed Fix
- Track the Init failure and short-circuit later write/watch calls.
- Attempt to
dlopen("libx11.so.6")iflibX11.sois unavailable.
Metadata
Metadata
Assignees
Labels
No labels