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

Re: [PATCH] mingw: follow-up to "replace isatty() hack"

From
Johannes Sixt <j6t@kdbg.org>
Date
Jan 18, 2017, 21:16 UTC
Message-ID
<c329c981-2b92-13b5-0561-d1d2e3fa2803@kdbg.org>
In-Reply-To
<xmqq7f5s9nvt.fsf@gitster.mtv.corp.google.com>
Am 18.01.2017 um 20:19 schrieb Junio C Hamano:
Show 33 quoted lines
> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
>>  compat/winansi.c | 11 ++++-------
>>  1 file changed, 4 insertions(+), 7 deletions(-)
>>
>> diff --git a/compat/winansi.c b/compat/winansi.c
>> index 3c9ed3cfe0..82b89ab137 100644
>> --- a/compat/winansi.c
>> +++ b/compat/winansi.c
>> @@ -494,19 +494,16 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
>>  	 * It is because of this implicit close() that we created the
>>  	 * copy of the original.
>>  	 *
>> -	 * Note that the OS can recycle HANDLE (numbers) just like it
>> -	 * recycles fd (numbers), so we must update the cached value
>> -	 * of "console".  You can use GetFileType() to see that
>> -	 * handle and _get_osfhandle(fd) may have the same number
>> -	 * value, but they refer to different actual files now.
>> +	 * Note that we need to update the cached console handle to the
>> +	 * duplicated one because the dup2() call will implicitly close
>> +	 * the original one.
>>  	 *
>>  	 * Note that dup2() when given target := {0,1,2} will also
>>  	 * call SetStdHandle(), so we don't need to worry about that.
>>  	 */
>> -	dup2(new_fd, fd);
>>  	if (console == handle)
>>  		console = duplicate;
>> -	handle = INVALID_HANDLE_VALUE;
>> +	dup2(new_fd, fd);
>>
>>  	/* Close the temp fd.  This explicitly closes "new_handle"
>>  	 * (because it has been associated with it).
>>
Looks good and obviously correct (FLW). I can offer a
Reviewed-by: Johannes Sixt <j6t@kdbg.org>
but it will take a day or two until I can test the patch.
-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “mingw: follow-up to "replace isatty() hack"”
  1. mingw: follow-up to "replace isatty() hack"Johannes Schindelin, Jan 18, 2017
  2. Junio C HamanoJan 18, 2017
  3. Johannes SixtJan 18, 2017
  4. Junio C HamanoJan 18, 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.