Pádraig Brady wrote: > Perhaps fpurge() is needed on FreeBSD to avoid the repeated warning? > I don't have easy access to a FreeBSD machine at present, > to test this change: > > diff --git a/src/head.c b/src/head.c > index 7bba1420c..da32c886f 100644 > --- a/src/head.c > +++ b/src/head.c > @@ -181,6 +181,7 @@ xwrite_stdout (char const *buffer, size_t n_bytes) > if (n_bytes > 0 && fwrite (buffer, 1, n_bytes, stdout) < n_bytes) > { > clearerr (stdout); /* To avoid redundant close_stdout diagnostic. */ > + fpurge (stdout); > error (EXIT_FAILURE, errno, _("error writing %s"), > quoteaf ("standard output")); > } > diff --git a/src/system.h b/src/system.h > index 7b736604b..6f3abf529 100644 > --- a/src/system.h > +++ b/src/system.h > @@ -770,6 +770,7 @@ write_error (void) > { > int saved_errno = errno; > fflush (stdout); /* Ensure nothing buffered that might induce an > error. */ > + fpurge (stdout); > clearerr (stdout); /* To avoid extraneous diagnostic from close_stdout. > */ > error (EXIT_FAILURE, saved_errno, _("write error")); > }
This patch does not change the result on FreeBSD 13.2: FAIL: tests/ls/removed-directory But it fixes both the failure and the error on FreeBSD 13.1: FAIL: tests/head/head-write-error ERROR: tests/env/env-signal-handler More precisely, the src/head.c change on its own fixes the FAIL, but not the ERROR. And the src/system.h change on its own fixes the ERROR, but not the FAIL. Bruno