Re: [PATCH] Don't fflush(stdout) when it's not helpful
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 30, 2007, 18:42 UTC
- Message-ID
- <7vbqexcmim.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <alpine.LFD.0.98.0706292114350.8675@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 17 quoted lines
>> I was planning to push this out to 'master' this weekend.
>
> I think that code is fine, but switching the order around could probably
> make it less likely that stdio loses the errno for us.
>
> So doing the last part in a different order, and making it say
>
> /* Check for ENOSPC and EIO errors.. */
> if (fflush(stdout))
> die("write failure on standard output: %s", strerror(errno));
> if (ferror(stdout))
> die("unknown write failure on standard output");
> if (fclose(stdout))
> die("close failed on standard output: %s", strerror(errno));
> return 0;
>
> may recover at least non-transient errors.That makes sense, to a certain degree, given that we do not check every printf(). I'll forge your signature as usual ;-)
Thanks.