git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] mingw: make stderr unbuffered again

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 13, 2017, 22:39 UTC
Message-ID
<xmqqlgt9btrv.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<c88612da0a62bfcbc3e278296f9d3eb010057071.1487025228.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 16 quoted lines
> When removing the hack for isatty(), we actually removed more than just
> an isatty() hack: we removed the hack where internal data structures of
> the MSVC runtime are modified in order to redirect stdout/stderr.
>
> Instead of using that hack (that does not work with newer versions of
> the runtime, anyway), we replaced it by reopening the respective file
> descriptors.
>
> What we forgot was to mark stderr as unbuffered again.
>
> Reported by Hannes Sixt. Fixed with Jeff Hostetler's assistance.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
> Published-As: https://github.com/dscho/git/releases/tag/mingw-unbuffered-stderr-v1
> Fetch-It-Via: git fetch https://github.com/dscho/git mingw-unbuffered-stderr-v1

OK. Should this go directly to 'master', as the isatty thing is already in?

Show 28 quoted lines
>
>  compat/winansi.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/compat/winansi.c b/compat/winansi.c
> index 82b89ab1376..793420f9d0d 100644
> --- a/compat/winansi.c
> +++ b/compat/winansi.c
> @@ -510,6 +510,8 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
>  	 */
>  	close(new_fd);
>  
> +	if (fd == 2)
> +		setvbuf(stderr, NULL, _IONBF, BUFSIZ);
>  	fd_is_interactive[fd] |= FD_SWAPPED;
>  
>  	return duplicate;
> @@ -547,6 +549,8 @@ static void detect_msys_tty(int fd)
>  			!wcsstr(name, L"-pty"))
>  		return;
>  
> +	if (fd == 2)
> +		setvbuf(stderr, NULL, _IONBF, BUFSIZ);
>  	fd_is_interactive[fd] |= FD_MSYS;
>  }
>  
>
> base-commit: 5588dbffbd61e4906e453808c6ad32f792fea521
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 2 of 16 in “mingw: make stderr unbuffered again”
  1. mingw: make stderr unbuffered againJohannes Schindelin, Feb 13, 2017
  2. Junio C HamanoFeb 13, 2017
  3. Johannes SchindelinFeb 14, 2017
  4. Johannes SixtFeb 14, 2017
  5. Junio C HamanoFeb 14, 2017
  6. Johannes SchindelinFeb 15, 2017
  7. Johannes SixtFeb 15, 2017
  8. Johannes SchindelinFeb 16, 2017
  9. Johannes SixtFeb 16, 2017
  10. Junio C HamanoFeb 16, 2017
  11. Junio C HamanoFeb 14, 2017
  12. Johannes SchindelinFeb 15, 2017
  13. Junio C HamanoFeb 15, 2017
  14. Junio C HamanoFeb 15, 2017
  15. Johannes SchindelinFeb 17, 2017
  16. Junio C HamanoFeb 17, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.