Re: [PATCH] git-rev-list: give better diagnostic for failed write
- From
Theodore Tso <tytso@mit.edu>
- Date
- Jun 26, 2007, 17:11 UTC
- Message-ID
- <20070626171127.GA28810@thunk.org>
- In-Reply-To
- <alpine.LFD.0.98.0706251607000.8675@woody.linux-foundation.org>
On Mon, Jun 25, 2007 at 04:16:56PM -0700, Linus Torvalds wrote:
Show 6 quoted lines
> Again, this is something that a non-stdio-based buffering library would > easily handle. You could just test the file descriptor _once_ at the > beginning, to see if it's a regular file or not. And then you could have > the error handling where it belongs (when the IO is actually done, and the > error actually happens) rather than in the callers using a bad interface > that sometimes loses 'errno'.
Is there something obviously wrong with doing something like this?
if ((fstat(fileno(stdout), &st) < 0) && !S_ISREG(st.st_mode)) setbuf(stdout, NULL);
This would change stdout to use completely unbuffered I/O we're not sending the output to a file.
- Ted