From owner-freebsd-hackers Thu Jan 4 17:15: 9 2001 From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 4 17:15:06 2001 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 166CA37B400 for ; Thu, 4 Jan 2001 17:15:06 -0800 (PST) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f051F4c15995; Thu, 4 Jan 2001 17:15:04 -0800 (PST) Date: Thu, 4 Jan 2001 17:15:04 -0800 From: Alfred Perlstein To: Chris Williams Cc: freebsd-hackers@FreeBSD.ORG, rozzin@geekspace.com Subject: Re: Strange fwrite() behavior in a+ mode Message-ID: <20010104171504.A15744@fw.wintelcom.net> References: <3A551ABD.DBC9BD5C@geekspace.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <3A551ABD.DBC9BD5C@geekspace.com>; from psion@geekspace.com on Thu, Jan 04, 2001 at 07:52:13PM -0500 Sender: bright@fw.wintelcom.net Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Chris Williams [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