cksum: line-buffer the printed checksums
authorPádraig Brady <P@draigBrady.com>
Mon, 28 May 2012 01:43:06 +0000 (02:43 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 28 May 2012 01:50:11 +0000 (02:50 +0100)
This utility was inadvertently omitted from commit v8.0-34-g710fe41
* src/cksum.c (main): Set stdout to line buffered mode, to ensure
parallel running instances don't intersperse their output.
* NEWS: Mention the fix.
* THANKS.in: Add Anoop.
Reported by Anoop Sharma.

NEWS
THANKS.in
src/cksum.c

diff --git a/NEWS b/NEWS
index 78e1d72..daea549 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  cksum now prints checksums atomically so that concurrent
+  processes will not intersperse their output.
+  [the bug dates back to the initial implementation]
+
   ls --color would mis-color relative-named symlinks in /
   [bug introduced in coreutils-8.17]
 
index 4dd8e44..43c9d6b 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
@@ -57,6 +57,7 @@ Andrew Tridgell                     tridge@samba.org
 Andrey Borzenkov                    arvidjaar@mail.ru
 Andries Brouwer                     Andries.Brouwer@cwi.nl
 Andy Longton                        alongton@metamark.com
+Anoop Sharma                        sendtoanoop@gmail.com
 Anthony Thyssen                     anthony@griffith.edu.au
 Antonio Rendas                      ajrendas@yahoo.com
 Ariel Faigon                        ariel@cthulhu.engr.sgi.com
index d3ce0f8..332f41d 100644 (file)
@@ -290,6 +290,10 @@ 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);
+
   parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE, Version,
                       usage, AUTHORS, (char const *) NULL);
   if (getopt_long (argc, argv, "", NULL, NULL) != -1)