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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

You can provoke this behavior by running a "tig blame" that
takes a few seconds and then resizing the terminal that tig
is running in (you should get an incomplete blame output and
the error "Failed to read: Success").

Signed-off-by: Jeff King <peff@xxxxxxxx>
---
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.

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

 tig.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tig.c b/tig.c
index 6b111e4..8362ecf 100644
--- a/tig.c
+++ b/tig.c
@@ -2392,7 +2392,7 @@ update_view(struct view *view)
 	update_view_title(view);
 
 check_pipe:
-	if (ferror(view->pipe)) {
+	if (ferror(view->pipe) && errno != 0) {
 		report("Failed to read: %s", strerror(errno));
 		end_update(view, TRUE);
 
-- 
1.6.0.98.g0d3cc
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux