* src/cksum.c (main): Avoid the overhead of line buffering with -z,
which might also negatively impact the interleaved output if
there were newlines in file names.
---
 src/cksum.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/cksum.c b/src/cksum.c
index 1fdfcf8fd..9d9b9e157 100644
--- a/src/cksum.c
+++ b/src/cksum.c
@@ -1605,10 +1605,6 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  /* Line buffer stdout to ensure lines are written atomically and immediately
-     so that processes running in parallel do not intersperse their output.  */
-  setvbuf (stdout, NULL, _IOLBF, 0);
-
 #if HASH_ALGO_SUM
   char const *short_opts = "rs";
 #elif HASH_ALGO_CKSUM
@@ -1710,6 +1706,11 @@ main (int argc, char **argv)
         usage (EXIT_FAILURE);
       }
 
+  /* Flush newline-delimited records promptly
+     so that processes running in parallel avoid interspersing their output.  
*/
+  if (digest_delim == '\n')
+    setvbuf (stdout, NULL, _IOLBF, 0);
+
   min_digest_line_length = MIN_DIGEST_LINE_LENGTH;
 #if HASH_ALGO_BLAKE2 || HASH_ALGO_CKSUM
 # if HASH_ALGO_CKSUM
-- 
2.56.0


Reply via email to