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

Re: [tig PATCH] continue updates when pipe read has errno "Success"

From
Jonas Fonseca <jonas.fonseca@gmail.com>
Date
Aug 22, 2008, 10:10 UTC
Message-ID
<2c6b72b30808220310v1083e860tef9fd6efa57767e3@mail.gmail.com>
In-Reply-To
<20080821014043.GA14452@coredump.intra.peff.net>
On Thu, Aug 21, 2008 at 03:40, Jeff King <peff@peff.net> wrote:
Show 5 quoted lines
> When we are reading from a pipe and receive a signal, our
> read call fails and ferror() returns true. The current
> behavior is to call end_update and report failure. However,
> we can detect this situation by checking that errno is set
> to success and continue the reading process.
Thanks for the fix/workaround!
Show 5 quoted lines
> I am not convinced this is the right solution. Specifically:
>
>  - there are a few other calls to ferror. Maybe they should be
>    converted, too, which implies that perhaps there is a better idiom
>    for checking this.
Well, perhaps something like this can work around the issue for tig-0.12:
bool check_ferror(FILE *file) { return ferror(file) && errno != 0; }

For a possible "better" fix, I have been working on moving tig to use the run-command.[ch] code from git, which means that ferror() will no longer be needed. It is still not ready but looks promising.

Show 6 quoted lines
>  - I have no idea how portable this is. Do all stdio implementations
>    fail to restart on signal? Do they all set ferror and have errno ==
>    0 (I would have expected EINTR, or at the very least a 0-read
>    without ferror set)?
>
> But it works for me (Linux, glibc 2.7).

I have tested it on FreeBSD which doesn't seem to have this problem with ferror(). Anyway, the workaround doesn't break anything so applied.

-- 
Jonas Fonseca
Previous: Jeff KingNext: Jeff King
Message 2 of 3 in “continue updates when pipe read has errno "Success"”
  1. continue updates when pipe read has errno "Success"Jeff King, Aug 21, 2008
  2. Jonas FonsecaAug 22, 2008
  3. Jeff KingAug 22, 2008

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.