[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#980764: libc6-dev: wrong return value for fputs when STDOUT_FILENO was closed()



* 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.


Reply to: