When running xlb function the code gets stuck in a native endless loop. The patch I have added closes the fd of the xserver, which as a side effect ends the endless loop. Some would say this patch is fixing a bug of a dependency of emacs and not emacs itself (it is just that emacs uses it in a certain way...).
This solution uses native timer (using signals) to detect the timeout. Upon reaching a timeout it closes an the fd on the same thread as the xlb code (this is because of how signals works).
To do this is lisp we need to answer the following:
1. How to find the fd of the current xserver using lisp?
2. How to call syscall close using lisp?
3. How to create native timers using lisp?
4. Is it even allowed to run lisp code while the main thread is in xlb native code (stack frame is deep inside other library and this other library was called from lisp).