• Bug#980764: libc6-dev: wrong return value for fputs when STDOUT_FILENO

    From Florian Weimer@21:1/5 to All on Sun Feb 7 12:30:02 2021
    XPost: linux.debian.bugs.dist

    * Morel Bérenger:

    * Bérenger:
    ...
    Why do you think this is a bug?

    POSIX 10031-2017 standard says:

    POSIX requires that if you manipulate the underlying file descriptor
    of a stream, you first need to call fseek when using the stream again.
    Your example code does not do that, so it's not following POSIX
    requirements for these interfaces.

    But there's another reason why POSIX requirements are met by the glibc implemetnation.

    In the error section, we can read that it can return the same errors
    (in errno) as fputc, which itself says, as for errors:

    [EBADF] The file descriptor underlying stream is not a valid file
    descriptor open for writing.

    The error is conditional:

    | The fputc() function shall fail if either the stream is unbuffered
    | or the stream's buffer needs to be flushed, and: […]

    As I explained, the stream is buffered because it is not connected to
    a terminal.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)