From: Pádraig Brady Date: Sat, 15 Jul 2023 20:55:23 +0000 (+0100) Subject: join: promptly diagnose write errors X-Git-Tag: v9.4~72 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02a4ebd6c451d013ecc4a93a809416781fbaf6ab;p=thirdparty%2Fcoreutils.git join: promptly diagnose write errors * 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. --- diff --git a/NEWS b/NEWS index 24c018374e..b21a2b74d8 100644 --- 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. diff --git a/src/join.c b/src/join.c index 5b58ed4d59..afbf0307e1 100644 --- a/src/join.c +++ b/src/join.c @@ -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. */ diff --git a/tests/misc/write-errors.sh b/tests/misc/write-errors.sh index a9e112c3a8..4f17028a26 100755 --- a/tests/misc/write-errors.sh +++ b/tests/misc/write-errors.sh @@ -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