You are not logged in.

#1 2019-06-29 13:37:19

Portal
Member
Registered: 2019-03-11
Posts: 48

x11 programming: fatal IO error 11 (Resource temporarily unavailable)

I am a complete noob at x11. I have a simple C program:

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
int main()
{
        Display *dpy;
        int screen;
        Window win;
        XEvent event;

        dpy=XOpenDisplay(NULL);
        if(dpy==NULL)
        {
                fprintf(stderr, "cant");
                exit(1);
        }
        screen=DefaultScreen(dpy);
        printf("%d %d", XDefaultDepth(dpy, screen), XDisplayPlanes(dpy, screen));

        win=XCreateSimpleWindow(dpy,RootWindow(dpy,screen) ,50,50,800,500,10, BlackPixel(dpy,screen), WhitePixel(dpy,screen));
        XSelectInput(dpy,win,ExposureMask | KeyPressMask);
        XMapWindow(dpy,win);

        while(1)
        {
                XNextEvent(dpy,&event);

        }
        return 0;
}

On line 21, I tried to display some infos about the screen. However, the program complained:

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

Offline

#2 2019-06-29 13:49:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: x11 programming: fatal IO error 11 (Resource temporarily unavailable)

It compiled and ran fine for me.  Are you sure that error is actually from the line you think it is?  Note that there is no newline in your format string, so the two numbers printed out could easily be covered by a later error (i.e. if you closed the window perhaps).

Last edited by Trilby (2019-06-29 13:50:44)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2019-06-30 02:16:08

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: x11 programming: fatal IO error 11 (Resource temporarily unavailable)

It did work after I added the newlines... shouldn't it still display even without the newlines? Can you explain more what you meant by

Trilby wrote:

the two numbers printed out could easily be covered by a later error (i.e. if you closed the window perhaps).

Offline

#4 2019-06-30 03:03:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: x11 programming: fatal IO error 11 (Resource temporarily unavailable)

It's possible that the error output included ansi codes to move the cursor to the start of the line.  However, even more likely is that the error message was from a separate thread that caused the program to exit, and due to IO buffering, the numbers were never flushed prior to the exit.

You could see this more directly by removing the newline(s) again, but adding a fflush(stdout) right after the print command.

But this has nothing to do with X, specifically, this is just general IO buffering.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2019-06-30 05:20:50

Portal
Member
Registered: 2019-03-11
Posts: 48

Re: x11 programming: fatal IO error 11 (Resource temporarily unavailable)

that makes sense thanks

Offline

Board footer

Powered by FluxBB