]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
groups: promptly diagnose write errors
authorCollin Funk <collin.funk1@gmail.com>
Thu, 26 Feb 2026 04:56:12 +0000 (20:56 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Fri, 27 Feb 2026 03:05:32 +0000 (19:05 -0800)
* 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'.

NEWS
src/groups.c
tests/misc/io-errors.sh

diff --git a/NEWS b/NEWS
index cf1b1414ed887e2fd5481c56727eb61ba7978ef3..7567a488f12ba86504d21c8620aae6e9e85913a9 100644 (file)
--- 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
index faed5c810c1a7f0b7a00477a4d9fd0ccc7119121..3daf410d9faeb29819931d6df1089578aa83c679 100644 (file)
@@ -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 ();
         }
     }
 
index 63649603ea491931bd0b8f8da87ceabacdc275c9..29929f652c91764449471f75bef44e149b773cc1 100755 (executable)
@@ -44,6 +44,7 @@ fmt foo
 fold foo
 fold -b foo
 fold -c foo
+groups
 head -n1 foo
 join foo foo
 nl foo