Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jan 2001 17:15:04 -0800
From:      Alfred Perlstein <bright@wintelcom.net>
To:        Chris Williams <psion@geekspace.com>
Cc:        freebsd-hackers@FreeBSD.ORG, rozzin@geekspace.com
Subject:   Re: Strange fwrite() behavior in a+ mode
Message-ID:  <20010104171504.A15744@fw.wintelcom.net>
In-Reply-To: <3A551ABD.DBC9BD5C@geekspace.com>; from psion@geekspace.com on Thu, Jan 04, 2001 at 07:52:13PM -0500
References:  <3A551ABD.DBC9BD5C@geekspace.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Chris Williams <psion@geekspace.com> [010104 16:51] wrote:
> If I run the following program, I get the following results:

[snip]

I wish you would have summarized that better...

> 
> It tells me I'm at 3, but my read acts as if I'm at the end of the file, and
> then after trying to read it tells me I'm at 13 (the end).
> 
> Is this a bug? Am I doing something illegal, and the behavior is random? Or..?
> 
> According to Rozzin (CCed, who brought the issue to my attention), under Linux
> he sees the first behavior (move pointer to end of file, and tell you that)
> consistantly.

from the manpage:

     ``a+''  Open for reading and writing.  The file is created if it does not
             exist.  The stream is positioned at the end of the file.  Subse-
             quent writes to the file will always end up at the then current
             end of file, irrespective of intervening fseek()s.

It doesn't say anything about reads.

So in Linux, if you have a "a+" file, you can
1) seek somewhere (mid file)
2) read some data (not until EOF)
3) after the read you are at EOF again?

this doesn't sound really intuative.

-- 
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010104171504.A15744>