From owner-freebsd-standards@FreeBSD.ORG Sat May 21 20:15:08 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 0307016A4CE for ; Sat, 21 May 2005 20:15:08 +0000 (GMT) Received: from storm.uk.FreeBSD.org (storm.uk.FreeBSD.org [194.242.157.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D6D543D55 for ; Sat, 21 May 2005 20:15:07 +0000 (GMT) (envelope-from mark@grondar.org) Received: from storm.uk.FreeBSD.org (uucp@localhost [127.0.0.1]) by storm.uk.FreeBSD.org (8.13.3/8.13.3) with ESMTP id j4LKF5XA029943; Sat, 21 May 2005 21:15:05 +0100 (BST) (envelope-from mark@grondar.org) Received: (from uucp@localhost)j4LKF3hS029939; Sat, 21 May 2005 21:15:03 +0100 (BST) (envelope-from mark@grondar.org) Received: from grondar.org (localhost [127.0.0.1]) by grovel.grondar.org (8.13.3/8.13.1) with ESMTP id j4LKDTMC070728; Sat, 21 May 2005 21:13:29 +0100 (BST) (envelope-from mark@grondar.org) Message-Id: <200505212013.j4LKDTMC070728@grovel.grondar.org> X-Mailer: exmh version 2.7.2 01/07/2005 with nmh-1.0.4 To: Steve Kargl From: Mark Murray In-Reply-To: Your message of "Sat, 21 May 2005 12:36:05 PDT." <20050521193605.GB51782@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 21 May 2005 21:13:29 +0100 Sender: mark@grondar.org cc: freebsd-standards@FreeBSD.ORG 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:15:08 -0000 Steve Kargl writes: > >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 ... abuses fread(3) return values. Try this: [grovel] ~ 09:10 pm $ cat test.c #include int main(void) { int i, j; FILE *fp; j = -1; fp = fopen("/dev/null", "r"); while((i = fread(&j, sizeof(int), 1, fp))) { printf("i = %d\nj = %d\n", i, j); if (feof(fp)) break; } printf("AT END\ni = %d\nj = %d\n", i, j); return 0; } [grovel] ~ 09:10 pm $ gcc -Wall test.c -o test [grovel] ~ 09:11 pm $ ./test AT END i = 0 j = -1 [grovel] ~ 09:11 pm $ M -- Mark Murray iumop ap!sdn w,I idlaH