Bruno Haible <[email protected]> writes:

> Collin Funk wrote:
>> The only realistic
>> solution I see is adding the following snippet to the start of each
>> program:
>> 
>>     #if MUSL_LIBC
>>       if (isatty (STDOUT_FILENO))
>>         setvbuf (stdout, NULL, _IOFBF, BUFSIZ);
>>     #endif
>
> This should be:
>
>      #if MUSL_LIBC
>        if (!isatty (STDOUT_FILENO))
>          setvbuf (stdout, NULL, _IOFBF, BUFSIZ);
>      #endif

Oops, thanks.

>> Given the number of programs, I obviously do not love that solution.
>
> We could implement this solution, through a Gnulib module, and activated
> through Gnulib module 'at-init'.
>
> The real question is: is this behaviour worth an extra system call at
> program start?

I would say yes if the program mistakenly succeeded. However, since it is
just a missing description from strerror, I think I am okay with just
skipping the test on musl.

I'll push the attached patch later if no one disagrees. It still checks
that the exit status is correct, but not for the strerror message.

Collin

>From d57c5dc7560c055114861d7f1ad34387319b20ef Mon Sep 17 00:00:00 2001
Message-ID: <d57c5dc7560c055114861d7f1ad34387319b20ef.1775700049.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Wed, 8 Apr 2026 18:57:54 -0700
Subject: [PATCH] tests: avoid a failure on musl

* tests/misc/io-errors.sh: Allow a generic error string on musl since
the first line is emitted immediately instead of being buffered as
expected.
Reported by Bruno Haible.
---
 tests/misc/io-errors.sh | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tests/misc/io-errors.sh b/tests/misc/io-errors.sh
index d8efee08a..6dbd30ce4 100755
--- a/tests/misc/io-errors.sh
+++ b/tests/misc/io-errors.sh
@@ -83,6 +83,15 @@ while read writer; do
   # For e.g. with _IOLBF etc, stdio will discard pending data at each line,
   # thus only giving a generic error upon ferror() in close_stream().
   error_re="$ENOSPC"
+
+  # musl writes the first line immediately when it should be fully buffered.
+  # As a result, when we print a single line there is no bytes buffered when
+  # we close the stream and errno is not set.  See:
+  # <https://www.openwall.com/lists/musl/2026/04/02/1>.
+  case $host_triplet in
+    *-musl*) error_re="$error_re|" ;;
+  esac
+
   printf '%s' "$writer" | grep 'generic' >/dev/null &&
     { error_re="write error|$error_re"; }
 
-- 
2.53.0

  • misc/io-errors fails on ... Bruno Haible via GNU coreutils General Discussion
    • Re: misc/io-errors ... Collin Funk
      • Re: misc/io-err... Bruno Haible via GNU coreutils General Discussion
        • Re: misc/io... Collin Funk
          • Re: mis... Bruno Haible via GNU coreutils General Discussion
            • Re... Collin Funk
              • ... Bruno Haible via GNU coreutils General Discussion
                • ... Bruno Haible via GNU coreutils General Discussion
                • ... Collin Funk
                • ... Bruno Haible via GNU coreutils General Discussion
                • ... Collin Funk
                • ... Bruno Haible via GNU coreutils General Discussion
                • ... Collin Funk
                • ... Bruno Haible via GNU coreutils General Discussion

Reply via email to