If I set error handler using xlib function XSetErrorHandler will this handler work for the whole process or only for a thread where XSetErrorHandler was called?
It should work for the whole process. It is not good for more than 1 thread to communicate with Xlib, because Xlib is not thread-safe.