git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jonas Fonseca" <jonas.fonseca@gmail.com>
To: "Jeff King" <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [tig PATCH] continue updates when pipe read has errno "Success"
Date: Fri, 22 Aug 2008 12:10:35 +0200	[thread overview]
Message-ID: <2c6b72b30808220310v1083e860tef9fd6efa57767e3@mail.gmail.com> (raw)
In-Reply-To: <20080821014043.GA14452@coredump.intra.peff.net>

On Thu, Aug 21, 2008 at 03:40, Jeff King <peff@peff.net> wrote:
> 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!

> 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.

>  - 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

  reply	other threads:[~2008-08-22 10:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21  1:40 [tig PATCH] continue updates when pipe read has errno "Success" Jeff King
2008-08-22 10:10 ` Jonas Fonseca [this message]
2008-08-22 15:59   ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c6b72b30808220310v1083e860tef9fd6efa57767e3@mail.gmail.com \
    --to=jonas.fonseca@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).