Collin Funk <[email protected]> writes:

>> Though that got me thinking that commands with --files0-from
>> can have indefinite output, so I adjusted du and wc to output early
>> and added tests in the attached.
>
> Nice catch. I pushed my patch. I'll let you decide if you want to merge
> the NEWS entries into one, or leave them seperate to describe the
> rationale for each case.

Oh, I realized that 'cksum' cant write for a long time too:

    $ dd if=/dev/random of=input bs=1024 \
        count=$(($(numfmt --from=iec 512M) / 1024)) status=none
    $ env time --format=%E cksum -a sha3 --length 256 \
        $(yes input | head -n 10) > /dev/full
    cksum: write error
    Command exited with non-zero status 1
    0:11.53
    $ env time --format=%E cksum --check check > /dev/full
    cksum: write error
    Command exited with non-zero status 1
    0:11.64

This patch should fix it like so:

    $ env time --format=%E ./src/cksum -a sha3 --length 256 \
        $(yes input | head -n 10) > /dev/full
    cksum: write error: No space left on device
    Command exited with non-zero status 1
    0:01.15
    $ env time --format=%E ./src/cksum --check check > /dev/full
    cksum: write error: No space left on device
    Command exited with non-zero status 1
    0:01.14

I'll add some tests later before pushing.

Collin

diff --git a/src/cksum.c b/src/cksum.c
index 2c5cdfbe1..7d6ff982b 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -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));

Reply via email to