Skip to content

mingw: fix isatty() after dup2() - #61

Closed
dscho wants to merge 1 commit into
gitgitgadget:masterfrom
dscho:mingw-isatty-and-dup2
Closed

dscho wants to merge 1 commit into
gitgitgadget:masterfrom
dscho:mingw-isatty-and-dup2

Conversation

@dscho

@dscho dscho commented Oct 30, 2018 •

Copy link
Copy Markdown
Member

This patch has been looong in the waiting (well over a year) for being sent to the Git mailing list; it is a fixup for a change of isatty() on Windows that had long made it into git.git's master branch.

Since a9b8a09 (mingw: replace isatty() hack, 2016-12-22), we handle
isatty() by special-casing the stdin/stdout/stderr file descriptors,
caching the return value. However, we missed the case where dup2()
overrides the respective file descriptor.

That poses a problem e.g. where the `show` builtin asks for a pager very
early, the `setup_pager()` function sets the pager depending on the
return value of `isatty()` and then redirects stdout. Subsequently,
`cmd_log_init_finish()` calls `setup_pager()` *again*. What should
happen now is that `isatty()` reports that stdout is *not* a TTY and
consequently stdout should be left alone.

Let's override dup2() to handle this appropriately.

This fixes git-for-windows#1077

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho mentioned this pull request Oct 30, 2018
35 tasks done
@dscho
dscho requested a review from jeffhostetler October 30, 2018 16:21
@dscho

dscho commented Oct 30, 2018

Copy link
Copy Markdown
Member Author

/submit

@gitgitgadget

gitgitgadget Bot commented Oct 30, 2018

Copy link
Copy Markdown

Submitted as pull.61.git.gitgitgadget@gmail.com

@dscho

dscho commented Dec 15, 2018

Copy link
Copy Markdown
Member Author

Merged into master via fbfdc07

@dscho dscho closed this Dec 15, 2018
@dscho
dscho deleted the mingw-isatty-and-dup2 branch December 15, 2018 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant