Skip to content

Commit 204ec03

Browse files
author
Git for Windows Build Agent
committed
Merge branch 'mingw-isatty-fixup-v3'
This is an evil merge: it changes more than the merged commits, as the merged branch replaces part of the MSVC patches. This mess will need to be cleaned up in the next merging rebase, by moving the mingw-isatty-fixup patches in front of the MSVC patches. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents c5ad17a + fb0e18e commit 204ec03

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

compat/winansi.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -494,19 +494,16 @@ static HANDLE swap_osfhnd(int fd, HANDLE new_handle)
494494
* It is because of this implicit close() that we created the
495495
* copy of the original.
496496
*
497-
* Note that the OS can recycle HANDLE (numbers) just like it
498-
* recycles fd (numbers), so we must update the cached value
499-
* of "console". You can use GetFileType() to see that
500-
* handle and _get_osfhandle(fd) may have the same number
501-
* value, but they refer to different actual files now.
497+
* Note that we need to update the cached console handle to the
498+
* duplicated one because the dup2() call will implicitly close
499+
* the original one.
502500
*
503501
* Note that dup2() when given target := {0,1,2} will also
504502
* call SetStdHandle(), so we don't need to worry about that.
505503
*/
506-
dup2(new_fd, fd);
507504
if (console == handle)
508505
console = duplicate;
509-
handle = INVALID_HANDLE_VALUE;
506+
dup2(new_fd, fd);
510507

511508
/* Close the temp fd. This explicitly closes "new_handle"
512509
* (because it has been associated with it).

0 commit comments

Comments
 (0)