From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 7 15:04:33 2008 Return-Path: Delivered-To: hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C8BE7106569D; Thu, 7 Aug 2008 15:04:33 +0000 (UTC) (envelope-from gabor@kovesdan.org) Received: from server.mypc.hu (server.mypc.hu [87.229.73.95]) by mx1.freebsd.org (Postfix) with ESMTP id 82D6E8FC1F; Thu, 7 Aug 2008 15:04:33 +0000 (UTC) (envelope-from gabor@kovesdan.org) Received: from localhost (localhost [127.0.0.1]) by server.mypc.hu (Postfix) with ESMTP id 6314814D69C2; Thu, 7 Aug 2008 16:46:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at t-hosting.hu Received: from server.mypc.hu ([127.0.0.1]) by localhost (server.mypc.hu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Yo63A7PAMqyW; Thu, 7 Aug 2008 16:46:45 +0200 (CEST) Received: from [192.168.1.146] (catv-50629c59.catv.broadband.hu [80.98.156.89]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by server.mypc.hu (Postfix) with ESMTPSA id 0149F14D69C0; Thu, 7 Aug 2008 16:46:44 +0200 (CEST) Message-ID: <489B0ACD.80008@kovesdan.org> Date: Thu, 07 Aug 2008 16:46:37 +0200 From: Gabor Kovesdan User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: hackers@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 07 Aug 2008 15:49:03 +0000 Cc: fjoe@FreeBSD.org Subject: strange issue reading /dev/null X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 15:04:33 -0000 Hello, I'm wondering why fgetc() returns 0xff if called with /dev/null: #include #include int main(void) { int c; FILE *f; f = fopen("/dev/null", "r"); if (c != EOF) printf("%c\n", fgetc(f)); } > gcc foo.c > ./a.out ˙ This causes a bug in BSD grep as /dev/null is not distinguished from ordinary files in the code, thus I was expecting it just returned EOF, but in reality this is not the case. How such cases should be handled? Thanks in advance, Gábor