]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
id: promptly diagnose write errors
authorCollin Funk <collin.funk1@gmail.com>
Thu, 26 Feb 2026 04:59:35 +0000 (20:59 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Fri, 27 Feb 2026 03:07:21 +0000 (19:07 -0800)
* NEWS: Mention the improvement.
* src/id.c (print_stuff): Call fflush for each listed user to check for
write errors.
* tests/misc/io-errors.sh: Add an invocation of 'id'.

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

diff --git a/NEWS b/NEWS
index 7567a488f12ba86504d21c8620aae6e9e85913a9..a01a13acc234168be0ffcd80ef2e03424cf88e1b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,8 +18,8 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Improvements
 
-  'groups' will now exit immediately upon receiving a write error, which is
-  significant when listing information for many users.
+  'groups' and 'id' 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.
 
index 9ba880ad889bde288d892c2194964d298fc09ce8..02c3bf9b505fe730350d409704e4cb9e1565f673 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -458,4 +458,7 @@ print_stuff (char const *pw_name)
     {
       putchar (opt_zero ? '\0' : '\n');
     }
+
+  if (fflush (stdout) < 0)
+    write_error ();
 }
index 29929f652c91764449471f75bef44e149b773cc1..e947df142b3c798062a74deaf73b7942a4ac90de 100755 (executable)
@@ -46,6 +46,7 @@ fold -b foo
 fold -c foo
 groups
 head -n1 foo
+id
 join foo foo
 nl foo
 numfmt --invalid=ignore < foo