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'.
This commit is contained in:
Collin Funk committed 2026-02-26 19:05:32 -08:00
1 parent 224588ce47
commit 80b229be71
3 files changed
+7

No files matched your search

+3
View File
@@ -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
+3
View 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 ();
}
}
+1
View File
@@ -44,6 +44,7 @@ fmt foo
fold foo
fold -b foo
fold -c foo
groups
head -n1 foo
join foo foo
nl foo