NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: xsrc/55853: [dM] xdpyinfo sometimes loses output



The following reply was made to PR xsrc/55853; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: Mouse <mouse%Rodents-Montreal.ORG@localhost>
Cc: gnats-bugs%NetBSD.org@localhost
Subject: Re: xsrc/55853: [dM] xdpyinfo sometimes loses output
Date: Wed, 9 Dec 2020 05:34:25 +0000 (UTC)

 This looks like a problem caused by fully-buffered writes:
 
 $ uname -a
 NetBSD x202e.localdomain 9.99.76 NetBSD 9.99.76 (GENERIC) #0: Wed Dec  2 
 02:21:43 UTC 2020 
 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
 
 $ xdpyinfo | wc -c
     65536
 $ xdpyinfo > /tmp/x.txt
 $ wc -c /tmp/x.txt
     65536 /tmp/x.txt
 $
 
 Precisely 64K each time. Make writes to stdout line-buffered:
 
 $ env STDBUF1=L xdpyinfo | wc -c
     67792
 $
 
 Success.
 
 Someone'll have to look into the libc/stdio/... code to see why
 fully-buffered output streams are not being flushed before a
 program exits.
 
 In the meantime, the "fix" for this _specific_ problem is simple:
 
 ---START PATCH---
 diff -urN xdpyinfo-1.3.2.orig/xdpyinfo.c xdpyinfo-1.3.2/xdpyinfo.c
 --- xdpyinfo-1.3.2.orig/xdpyinfo.c      2015-04-17 06:00:20.000000000 
 +0000
 +++ xdpyinfo-1.3.2/xdpyinfo.c   2020-12-09 05:24:58.749772471 +0000
 @@ -1501,6 +1501,7 @@
       }
 
       print_marked_extensions(dpy);
 +    fflush(NULL);
 
       XCloseDisplay (dpy);
       exit (0);
 ---END PATCH---
 
 We flush all output streams explicitly.
 
 -RVP
 



Home | Main Index | Thread Index | Old Index