This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Unbuffer stdout and stderr on windows
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Eli Zaretskii <eliz at gnu dot org>, yao at codesourcery dot com, brobecker at adacore dot com
- Date: Fri, 16 Aug 2013 16:23:58 +0100
- Subject: Re: [PATCH] Unbuffer stdout and stderr on windows
- References: <51EE23F8 dot 1070905 at codesourcery dot com> <83wqohw4ee dot fsf at gnu dot org> <20130729192559 dot GA5348 at ednor dot casa dot cgf dot cx> <83d2q1xiyv dot fsf at gnu dot org> <51F6C7B2 dot 3020400 at redhat dot com> <20130731034045 dot GA5565 at ednor dot casa dot cgf dot cx> <20130812211105 dot GA11128 at adacore dot com> <8361v9piop dot fsf at gnu dot org> <20130815173618 dot GA6955 at ednor dot casa dot cgf dot cx> <83eh9uonlg dot fsf at gnu dot org> <20130815175940 dot GD6955 at ednor dot casa dot cgf dot cx> <520E1109 dot 7000304 at redhat dot com> <520E1C34 dot 2000907 at codesourcery dot com> <520E2B13 dot 8020706 at redhat dot com> <83r4dtn35q dot fsf at gnu dot org> <520E357E dot 6080803 at redhat dot com> <83mwohn0nj dot fsf at gnu dot org> <520E40CD dot 7080604 at redhat dot com>
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