From owner-freebsd-standards@FreeBSD.ORG Sat May 21 20:14:47 2005 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE20016A568 for ; Sat, 21 May 2005 20:14:47 +0000 (GMT) Received: from gidgate.gid.co.uk (gid.co.uk [194.32.164.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4FA6F43D55 for ; Sat, 21 May 2005 20:14:46 +0000 (GMT) (envelope-from rb@gid.co.uk) Received: (from rb@localhost) by gidgate.gid.co.uk (8.11.7/8.11.6) id j4LKEj414941; Sat, 21 May 2005 21:14:45 +0100 (BST) (envelope-from rb) Message-Id: <6.2.0.14.2.20050521211303.04837368@gid.co.uk> X-Mailer: QUALCOMM Windows Eudora Version 6.2.0.14 Date: Sat, 21 May 2005 21:14:34 +0100 To: Steve Kargl , freebsd-standards@freebsd.org From: Bob Bishop In-Reply-To: <20050521193605.GB51782@troutmask.apl.washington.edu> References: <20050521193605.GB51782@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: Read /dev/null differs from POSIX X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 May 2005 20:14:48 -0000 At 20:36 21/05/2005, Steve Kargl wrote: > >From http://www.opengroup.org/onlinepubs/009695399/toc.htm > > /dev/null -- An infinite data source and data sink. Data > written to /dev/null shall be discarded. Reads from > /dev/null shall always return end-of-file (EOF). > >This program > > #include > int main(void) { > int i=0,j; > FILE *fp; > fp = fopen("/dev/null", "r"); > while(fread(&j, sizeof(int), 1, fp) != 1) { > i++; > if (i == 5) break; > } > printf("i = %d\n", i); > if (j == EOF) > printf("EOF\n"); > else > printf("j = %d\n", j); >} > >prints > >i = 5 >j = 1 > >Is this historic BSD defacto behavior? When fread hits EOF, it doesn't write to j. -- Bob Bishop +44 (0)118 940 1243 rb@gid.co.uk fax +44 (0)118 940 1295