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

Re: [msysGit] [PATCH] mingw: work around stat-limitation

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Feb 23, 2012, 21:36 UTC
Message-ID
<CABPQNSZ+=no5PKkaa8_44FbOzh_W4A5knoxKgDQ2wTvOaeKdew@mail.gmail.com>
In-Reply-To
<alpine.DEB.1.00.1202231525320.3340@s15462909.onlinehome-server.info>

On Thu, Feb 23, 2012 at 10:26 PM, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

Show 16 quoted lines
> Hi,
>
> On Thu, 23 Feb 2012, Erik Faye-Lund wrote:
>
>> Our stat implementation for Windows always sets st_ino to 0. This
>> means that checking if isatty(0) and comparing the reported inodes
>> of stdout and stdin is not sufficient to detect that both are
>> pointing to the same TTY.
>>
>> Luckily, there's only one console on Windows, so adding a check for
>> isatty(1) should do the trick. For platforms where inodes are
>> reported correctly, this should still be correct.
>
> Sorry to ask so stupidly, but why does isatty(1) work and isatty(0) does
> not? Should they not access the very same console object?
>

The point is that they might not. The old test would draw the wrong conclusion if isatty(0) was true, but isatty(1) was not because it used st_ino to verify that stdin and stdout pointed to the same terminal. The reason it did that was to catch cases where stdin and stdout pointed to different terminals, AFAICT. Not checking isatty(1) was simply an optimization, which works when st_ino is filled out correctly.

On Windows there is only one terminal, so it's sufficient to check if both are connected.

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 4 in “mingw: work around stat-limitation”
  1. mingw: work around stat-limitationErik Faye-Lund, Feb 23, 2012
  2. Johannes SchindelinFeb 23, 2012
  3. Erik Faye-LundFeb 23, 2012
  4. Johannes SchindelinFeb 23, 2012

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.