detect write failure, even for stdout
- From
Jim Meyering <jim@meyering.net>
- Date
- May 22, 2006, 10:27 UTC
- Message-ID
- <87d5e6gxr0.fsf_-_@rho.meyering.net>
- In-Reply-To
- <7v3bf3jl15.fsf@assigned-by-dhcp.cox.net>
git doesn't always detect write failures. A write I/O error, (e.g., hardware I/O error or simply disk full) doesn't provoke nonzero exit status:
$ ./git-cat-file -t HEAD > /dev/full && echo did not detect write failure
did not detect write failureThis is perhaps more important than the other things I've reported, since it can lead to porcelain being unable to detect a real failure in the plumbing.
Here are two more:
$ ./git-ls-tree HEAD > /dev/full && echo fail
fail
$ ./git-show > /dev/full && echo fail
failIf you were using gnulib, I'd suggest simply adding this line
atexit (close_stdout);
near the beginning of each `main'. Then you wouldn't have to manually track down each and every place where a write to stdout can occur -- not to mention the maintenance burden of keeping things correct as the code evolves.