1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-02-10 17:31:56 +02:00

cksum: promptly diagnose write errors

* src/cksum.c (output_file, digest_check): Check if standard output has
it's error flag set after printing.
* tests/misc/write-errors.sh: Add a test case that would previously run
forever.
* NEWS: Mention the improvement. Reorder alphabetically.
This commit is contained in:
Collin Funk
2026-01-09 21:17:26 -08:00
parent a9aad49f26
commit 3621ad2f71
3 changed files with 12 additions and 3 deletions

6
NEWS
View File

@@ -73,14 +73,14 @@ GNU coreutils NEWS -*- outline -*-
'cksum' now validates its options more consistently.
E.g., `cksum --text --tag` now fails like `cksum --tag --text` already did.
'cksum', 'du', and 'wc' now exit promptly upon receiving a write
error, which is significant when processing many input files.
csplit, ls, and sort, now handle a more complete set of terminating signals.
'du' now processes directories with 10,000 or more entries up to 9 times
faster on the Lustre file system.
'du', and 'wc' now exit promptly upon receiving a write error,
which is significant when processing many input files.
'pinky' will now exit immediately upon receiving a write error, which is
significant when reading large plan or project files.

View File

@@ -1266,6 +1266,9 @@ output_file (char const *file, int binary_file, void const *digest,
}
putchar (delim);
if (ferror (stdout))
write_error ();
}
#endif
@@ -1447,6 +1450,9 @@ digest_check (char const *checkfile_name)
printf (": %s\n", _("OK"));
}
}
if (ferror (stdout))
write_error ();
}
}
while (!feof (checkfile_stream) && !ferror (checkfile_stream));

View File

@@ -24,11 +24,14 @@ if ! test -w /dev/full || ! test -c /dev/full; then
skip_ '/dev/full is required'
fi
dev_null_hash=$(cksum -a sha3 -l 256 /dev/null) || framework_failure_
# Writers that may output data indefinitely.
# First word in command line is checked against built programs.
# Escapes must be double escaped.
printf '%s' "\
cat /dev/zero
cksum --version; yes '${dev_null_hash}' | cksum --check
comm -z /dev/zero /dev/zero
cut -z -c1- /dev/zero
cut -z -f1- /dev/zero