Ungrab X as quickly as possible and close display - xscreenshot - screen capture tool
 (HTM) git clone git://git.codemadness.org/xscreenshot
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 540d4dc0fb64b33d5f8050cc80affe513c37199e
 (DIR) parent 1cf03c53b280d3fe21dac843504dd54e9b64e4b6
 (HTM) Author: sin <sin@2f30.org>
       Date:   Mon, 28 Jul 2014 12:46:00 +0100
       
       Ungrab X as quickly as possible and close display
       
       Avoids deadlock when trying to output to stdout but the terminal
       can't process any events because of the grabbed X.
       
       Diffstat:
         M xscreenshot.c                       |       5 ++---
       
       1 file changed, 2 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/xscreenshot.c b/xscreenshot.c
       @@ -119,15 +119,14 @@ main(int argc, char *argv[])
        
                XGrabServer(dpy);
                XGetWindowAttributes(dpy, win, &attr);
       -
                img = XGetImage(dpy, win, 0, 0, attr.width, attr.height, 0xffffffff,
                                ZPixmap);
       +        XUngrabServer(dpy);
       +        XCloseDisplay(dpy);
                if(!img)
                        die("Can't XGetImage");
                pngstdout(img);
                XDestroyImage(img);
       -        XUngrabServer(dpy);
       -        XCloseDisplay(dpy);
        
                return EXIT_SUCCESS;
        }