From: Collin Funk Date: Thu, 26 Feb 2026 04:56:12 +0000 (-0800) Subject: groups: promptly diagnose write errors X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80b229be7187a24e14739291df54c7e15fb74fa5;p=thirdparty%2Fcoreutils.git groups: promptly diagnose write errors * NEWS: Mention the improvement. * src/groups.c (main): Call fflush for each listed user to check for write errors. * tests/misc/io-errors.sh: Add an invocation of 'groups'. --- diff --git a/NEWS b/NEWS index cf1b1414ed..7567a488f1 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ GNU coreutils NEWS -*- outline -*- ** Improvements + 'groups' will now exit immediately upon receiving a write error, which is + significant when listing information for many users. + 'nl' now supports multi-byte --section-delimiter characters. 'shuf -i' now operates up to two times faster on systems with unlocked stdio diff --git a/src/groups.c b/src/groups.c index faed5c810c..3daf410d9f 100644 --- a/src/groups.c +++ b/src/groups.c @@ -134,6 +134,9 @@ main (int argc, char **argv) if (!print_group_list (argv[optind], ruid, rgid, egid, true, ' ')) ok = false; putchar ('\n'); + + if (fflush (stdout) < 0) + write_error (); } } diff --git a/tests/misc/io-errors.sh b/tests/misc/io-errors.sh index 63649603ea..29929f652c 100755 --- a/tests/misc/io-errors.sh +++ b/tests/misc/io-errors.sh @@ -44,6 +44,7 @@ fmt foo fold foo fold -b foo fold -c foo +groups head -n1 foo join foo foo nl foo