[Spam?]Re: problem concating (>>) to a large file

Eric Blake ebb9@byu.net
Tue May 29 16:17:00 GMT 2007

Corinna Vinschen <corinna-cygwin <at> cygwin.com> writes:

> > 
> > assert (0 == lseek (open("existing", O_WRONLY | O_APPEND), 0, SEEK_CUR));
> Can you give me a pointer?

"The file offset used to mark the current position within the file shall be set 
to the beginning of the file."

This is stated prior to any mention of O_APPEND, and O_APPEND does not change 
that statement.  And for O_APPEND|O_RDWR, it is a necessity.

Later, in http://www.opengroup.org/onlinepubs/009695399/functions/write.html:
"If the O_APPEND flag of the file status flags is set, the file offset shall be 
set to the end of the file prior to each write and no intervening file 
modification operation shall occur between changing the file offset and the 
write operation."


int fd = open("existing", O_WRONLY | O_APPEND);
assert (0 == lseek (fd, 0, SEEK_CUR);
if (write (fd, " ", 1) > 0)
    assert (0 != lseek (fd, 0, SEEK_CUR));
    assert (lseek (fd, 0, SEEK_CUR) == lseek (fd, 0, SEEK_END));

Eric Blake

Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

More information about the Cygwin mailing list