www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/02/19/10:04:10

From: ian AT cygnus DOT com (Ian Lance Taylor)
Subject: Re: The alleged newlib/libc/stdio/fdopen.c bug
19 Feb 1998 10:04:10 -0800 :
Message-ID: <199802191601.LAA13945.cygnus.cygwin32.developers@subrogation.cygnus.com>
References: <01BD3D21 DOT 973CA0F0 AT gater DOT krystalbank DOT msk DOT ru>
To: sos AT prospect DOT com DOT ru
Cc: cygwin32-developers AT cygnus DOT com

   From: Sergey Okhapkin <sos AT prospect DOT com DOT ru>
   Date: Thu, 19 Feb 1998 10:31:50 +0300

   > That is correct for O_APPEND: every write should go to the end of the
   > file, wherever the end of the file happens to be at that time.  For
   > example, on Unix this can be used for writing log files from several
   > processes; provided each write is done in a single call, if you use
   > O_APPEND then you know that none of the writes will clobber another.

   This behavior doesn't works with gnu CSSC. The code makes fdopen(fd, 
   O_APPEND), writes some lines to the end of file, seeks to the beginning of 
   file and writes new file header. With this patch new file header will be 
   written to the end of file!

I just checked POSIX.1, and in the description of the open call it
says:

    O_APPEND: If set, the file offset shall be set to the end of the
    file prior to each write.

The ISO C standard says of fopen:

    Opening a file with append mode ('a' as the first character in the
    mode argument) causes all subsequent writes to the file to be
    forced to the then current end-of-file, regardless of intervening
    calls to the fseek function.

So gnu CSSC (I don't know what that is) is wrong, unless it is using
fcntl to turn off the O_APPEND flag before seeking to the start of the
file.

Ian

- Raw text -


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