Date: Mon, 4 Jun 2001 10:11:11 +0300 (IDT) From: Eli Zaretskii X-Sender: eliz AT is To: "Mark E." cc: djgpp-workers AT delorie DOT com Subject: Re: file append problem In-Reply-To: <3B1AD91B.15461.664B37@localhost> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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.