On 15/03/2026 03:45, Collin Funk wrote:
I wasn't too sure why 'tee' used streams to be honest. It looks like
it was for an option that was never implemented:
commit 8ddf2904779fefb47e4caa68632341a22f18cffa
Author: Jim Meyering <[email protected]>
AuthorDate: Mon Jul 26 07:11:27 1999 +0000
Commit: Jim Meyering <[email protected]>
CommitDate: Mon Jul 26 07:11:27 1999 +0000
(tee): Convert from open/fds to using fopen/streams for
output, in preparation for addition of new compression option.
My main rationale for this patch though is to make it easier to
experiment with things like splice.
I think this is a good change, as I previously considered:
https://lists.gnu.org/archive/html/coreutils/2015-03/msg00012.html
extern bool
-fwrite_wait (char const *buf, ssize_t size, FILE *f)
+write_wait (int fd, void const *buffer, size_t size)
{
- for (;;)
+ unsigned char const *buf = buffer;
+
+ while (true)
{
- const size_t written = fwrite (buf, 1, size, f);
+ ssize_t written = write (fd, buf, size);
+ if (written < 0)
+ {
+ if (errno == EINTR)
+ continue;
+ written = 0;
+ }
+
We could use safe_write() here,
but why the new consideration for EINTR at all?
Otherwise LGTM.
thanks!
Padraig