xcb errors are not handled at Xlib, gives fatal IO error 11 (Resource temporarily unavailable)
Submitted by Arvind Umrao
Assigned to Arvind Umrao
Description
xcb errors are not handled at Xlib. It gives
XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0" after 14 requests (13 known processed) with 0 events remaining.
Step to reproduce the problem Compile following code with cc test.c -lX11 then run ./a.out
close it with Ctrl-C
#include <X11/Xlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
Display *d;
Window w;
XEvent e;
char *msg = "Hello, World!";
int s;
d = XOpenDisplay(NULL);
if (d == NULL) {
fprintf(stderr, "Cannot open display\n");
exit(1);
}
s = DefaultScreen(d);
w = XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 200, 200, 1,
BlackPixel(d, s), WhitePixel(d, s));
/* select kind of events we are interested in */
XSelectInput(d, w, ExposureMask | KeyPressMask);
XMapWindow(d, w);
while (1) {
XNextEvent(d, &e);
/* draw or redraw the window */
if (e.type == Expose) {
XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
XDrawString(d, w, DefaultGC(d, s), 50, 50, msg, strlen(msg));
}
/* exit on key press */
if (e.type == KeyPress)
break;
}
XCloseDisplay(d);
return 0;
}
Edited by Ghost User