Re: [PATCH] Don't fflush(stdout) when it's not helpful
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 30, 2007, 02:15 UTC
- Message-ID
- <7vlke2dw6w.fsf@assigned-by-dhcp.pobox.com>
- In-Reply-To
- <alpine.LFD.0.98.0706291641590.8675@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 8 quoted lines
> On Fri, 29 Jun 2007, Theodore Tso wrote: >> >> Comments? > > Looks ok to me. > > This should probably be paired up with the change to git.c (in "next") to > do the "fflush()" before the "ferror()" too, in case the error is pending.
Do you mean this part?
+ /* Somebody closed stdout? */ + if (fstat(fileno(stdout), &st)) + return 0; + /* Ignore write errors for pipes and sockets.. */ + if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) + return 0; + + /* Check for ENOSPC and EIO errors.. */ + if (ferror(stdout)) + die("write failure on standard output"); + if (fflush(stdout) || fclose(stdout)) + die("write failure on standard output: %s", strerror(errno)); + + return 0; +}
I was planning to push this out to 'master' this weekend.