Similar to the last patch:
$ time ./src/id-prev $(yes collin | head -n 10000 | tr '\n' ' ') >&-
id-prev: write error: Bad file descriptor
real 0m42.127s
user 0m10.938s
sys 0m20.762s
$ time ./src/id $(yes collin | head -n 10000 | tr '\n' ' ') >&-
id: write error: Bad file descriptor
real 0m0.022s
user 0m0.003s
sys 0m0.021s
-- 8< --
* NEWS: Mention the improvement.
* src/id.c (print_stuff): Call fflush for each listed user to check for
write errors.
---
NEWS | 4 ++--
src/id.c | 3 +++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 13bb6031a..1dff767fa 100644
--- a/NEWS
+++ b/NEWS
@@ -18,8 +18,8 @@ GNU coreutils NEWS -*-
outline -*-
** Improvements
- 'group' will now exit immediately upon receiving a write error, which is
- significant when listing information for many users.
+ 'group' 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.
diff --git a/src/id.c b/src/id.c
index 9ba880ad8..02c3bf9b5 100644
--- 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 ();
}
--
2.53.0