delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/06/04/04:04:11

Date: Mon, 4 Jun 2001 10:11:11 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: "Mark E." <snowball3 AT bigfoot DOT com>
cc: djgpp-workers AT delorie DOT com
Subject: Re: file append problem
In-Reply-To: <3B1AD91B.15461.664B37@localhost>
Message-ID: <Pine.SUN.3.91.1010604100402.14670I-100000@is>
MIME-Version: 1.0
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

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019