After finding a similar problem in GNU grep, I audited coreutils for issues involving reading stdin twice, or neglecting to report read errors, and installed the attached. The 2nd patch does the real work; the rest is merely doc or Gnulib patches.