From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5354 invoked by alias); 16 Aug 2013 15:24:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 5340 invoked by uid 89); 16 Aug 2013 15:24:05 -0000 X-Spam-SWARE-Status: No, score=-8.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 16 Aug 2013 15:24:04 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7GFO0gW003412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 16 Aug 2013 11:24:00 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7GFNwn7005805; Fri, 16 Aug 2013 11:23:59 -0400 Message-ID: <520E440E.8020704@redhat.com> Date: Fri, 16 Aug 2013 15:24:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: Eli Zaretskii , yao@codesourcery.com, brobecker@adacore.com Subject: Re: [PATCH] Unbuffer stdout and stderr on windows References: <51EE23F8.1070905@codesourcery.com> <83wqohw4ee.fsf@gnu.org> <20130729192559.GA5348@ednor.casa.cgf.cx> <83d2q1xiyv.fsf@gnu.org> <51F6C7B2.3020400@redhat.com> <20130731034045.GA5565@ednor.casa.cgf.cx> <20130812211105.GA11128@adacore.com> <8361v9piop.fsf@gnu.org> <20130815173618.GA6955@ednor.casa.cgf.cx> <83eh9uonlg.fsf@gnu.org> <20130815175940.GD6955@ednor.casa.cgf.cx> <520E1109.7000304@redhat.com> <520E1C34.2000907@codesourcery.com> <520E2B13.8020706@redhat.com> <83r4dtn35q.fsf@gnu.org> <520E357E.6080803@redhat.com> <83mwohn0nj.fsf@gnu.org> <520E40CD.7080604@redhat.com> In-Reply-To: <520E40CD.7080604@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00440.txt.bz2 On 08/16/2013 04:10 PM, Pedro Alves wrote: >> A complete solution, if it exists, might require much more effort, > > I don't think it does. > > - First, make stderr always unbuffered. That's what you get on > most platforms anyway. > - Then, somewhere along fputs_unfiltered or some central output routine, > keep track of which was the last to be used between stdout and stderr. > If outputting to stderr, flush stdout first. Don't need to do the > opposite, since stderr will always be unbuffered. Or alternatively, like Tromey suggested, make fputs_unfiltered or some such implement line buffering internally (for Windows hosts), either by just forcing flushes at endlines (partial emulation), or with real local buffering. That potentially gets us a behavior on Windows/pipes even closer to other platforms. (His suggestion was kind of sidetracked by the \n -> \r\n bit, but that's actually a separate issue). (Neither solution looks that complicated to me.) -- Pedro Alves