delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/01/28/20:33:50

From: newsham AT aloha DOT net (Tim Newsham)
Subject: open and truncate
28 Jan 1997 20:33:50 -0800 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199701290157.PAA14023.cygnus.gnu-win32@haleakala.aloha.net>
Mime-Version: 1.0
Original-To: gnu-win32 AT cygnus DOT com
X-Mailer: ELM [version 2.4 PL24 PGP3 *ALPHA*]
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Hi,

    Open() will truncate existing files when the O_CREAT flag
is passed.  I mentioned this before and was told that this bug
is known.  I'm curious as to if its been fixed and will be
present in the next release or not.  Anyone know?

Details:
If you open an existing file with the O_CREAT flag set,
the file is opened and truncated to zero bytes:

    echo foo bar > test
    ...
        int fd = open("test", O_WRONLY | O_CREAT, 0666);
        close(fd);
    ...
    now "test" is an empty file

                                        Tim N.

-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


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