]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
join: promptly diagnose write errors
authorPádraig Brady <P@draigBrady.com>
Sat, 15 Jul 2023 20:55:23 +0000 (21:55 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 17 Jul 2023 10:28:36 +0000 (11:28 +0100)
* src/join.c (prjoin): Check for write errors after each line.
* tests/misc/write-errors.sh: enable the test for join.
* NEWS: Mention the improvement.

NEWS
src/join.c
tests/misc/write-errors.sh

diff --git a/NEWS b/NEWS
index 24c018374e8dd4436e3a107ab7627b76ba231717..b21a2b74d884e6c42926e6febe9ace24f4f17bec 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -62,7 +62,7 @@ GNU coreutils NEWS                                    -*- outline -*-
   irrespective of which kernel version coreutils is built against,
   reinstating that behaviour from coreutils-9.0.
 
-  comm, cut, od, and uniq will now exit immediately upon receiving a
+  comm, cut, join, od, and uniq will now exit immediately upon receiving a
   write error, which is significant when reading large / unbounded inputs.
 
   split now uses more tuned access patterns for its potentially large input.
index 5b58ed4d5963955383b363ea2e1a666bb8072f88..afbf0307e1fdf10d3f016049c329038a86f91b6b 100644 (file)
@@ -650,6 +650,9 @@ prjoin (struct line const *line1, struct line const *line2)
 
       putchar (eolchar);
     }
+
+  if (ferror (stdout))
+    write_error ();
 }
 
 /* Print the join of the files in FP1 and FP2.  */
index a9e112c3a857d4ad498486f0e44735e0e0f05e15..4f17028a26bf7353b905c4aa35372176655ef119 100755 (executable)
@@ -36,7 +36,7 @@ factor --version; yes 1 | factor
 # TODO: fmt /dev/zero
 # TODO: fold -b /dev/zero
 head -z -n-1 /dev/zero
-# TODO: join -a 1 -z /dev/zero /dev/null
+join -a 1 -z /dev/zero /dev/null
 # TODO: nl --version; yes | nl
 # TODO: numfmt --version; yes 1 | numfmt
 od -v /dev/zero