LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   "fatal IO error 11 (Resource temporarily unavailable) on X server" with two windows (https://www.linuxquestions.org/questions/linux-software-2/fatal-io-error-11-resource-temporarily-unavailable-on-x-server-with-two-windows-895783/)

10_GOTO_10 08-05-2011 02:44 PM

"fatal IO error 11 (Resource temporarily unavailable) on X server" with two windows
 
Hi,

I am programming on XLib with Code::blocks, and I have a crash when I opens two windows and I close one of them. I am on Ubuntu 10.10 64 bits, but it is the same thing on a virtual machine and Ubuntu 11.04 32 bits. the program is a sample "hello world" where I have just added a second window. The crash happens when I close one of the two windows:

Quote:

fatal IO error 11 (Resource temporarily unavailable) on X server ":0.0" after 16 requests (14 known processed) with 0 events remaining.

Process retourned 1 (0x1) execution time : 9.120 s
Press ENTER to continue
I have found this thread and this thread, but no one wich seems like my problem.

My code:

Quote:

/*
* xsimple : Affiche une chaine dans une fenetre X...
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _X_SENTINEL(x)
#include <X11/Xlib.h>

GC gc;
Display *display;
int screen;
Window win1, win2, root;
unsigned long white_pixel, black_pixel;


/*
* fonction associee a l'evenement EXPOSE
*/

void expose (Window win)
{
XDrawString (display, win, gc, 10, 30, "Hello, world !", 14);
}


/*
* programme principal
*/

int main(int ac, char **av) {
char *dpyn = NULL;

/* selection du display en ligne */
if (ac == 3) {
if (strcmp (&av[1][1], "display") == 0) {
dpyn = av[2];
}
else {
fprintf (stderr, "Usage: xsimple [-display display_name]\n");
exit (1);
}
}

if ((display = XOpenDisplay (dpyn)) == NULL) {
fprintf (stderr, "Can't open Display\n");
exit (1);
}

// XSetCloseDownMode(display, RetainTemporary /*RetainPermanent*/);

screen = DefaultScreen (display);
gc = DefaultGC (display, screen);
root = RootWindow (display, screen);
white_pixel = WhitePixel (display, screen);
black_pixel = BlackPixel (display, screen);


win1 = XCreateSimpleWindow (display, root, 0, 0, 200, 100, 2, black_pixel, white_pixel);
win2 = XCreateSimpleWindow (display, root, 300, 0, 200, 100, 2, black_pixel, white_pixel);

XSelectInput (display, win1, ExposureMask);
XSelectInput (display, win2, ExposureMask);

XStoreName (display, win1, "xsimple 1");
XMapWindow (display, win1);

XStoreName (display, win2, "xsimple 2");
XMapWindow (display, win2);


for ( ; ; ) {
XEvent ev;

XNextEvent (display, &ev);

switch (ev.type) {

case Expose :

expose (ev.xany.window);
break;

default :

break;

}
}
}
Thanks to all


All times are GMT -5. The time now is 02:09 PM.