Mail Archives: djgpp-workers/2001/06/04/04:04:11
On Mon, 4 Jun 2001, Mark E. wrote:
> The problem seems to be that fileno(stdout) gets its append flag set, but
> stdout doesn't. Because _flsbuf never checks its underlying fd to see if its
> append flag is set, it doesn't know it should perform a 'llseek(1, 0,
> SEEK_END)' before calling _write.
>
> I see two solutions:
> 1) Have _flsbuf (and other places where _IOAPPEND is checked) check whether
> the underlying fd has its append flag set before calling _write.
> 2) Add logic to _write to check whether a file descriptor's append flag is
> set and take action.
Doing so in _write seems a cleaner design, since O_APPEND emulates a
feature of the filesystem. However, it might be inappropriate to do that
in _write, because _write is documented as a direct interface to the OS.
So I think the append flag needs to be tested by any Posix function that
calls _write directly.
- Raw text -