From: Junio C Hamano Date: Sat, 30 Jun 2007 18:42:09 GMT Subject: Re: [PATCH] Don't fflush(stdout) when it's not helpful Message-ID: <7vbqexcmim.fsf@assigned-by-dhcp.cox.net> In-Reply-To: Linus Torvalds writes: >> 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.