From owner-freebsd-arch@FreeBSD.ORG Wed Feb 27 19:02:14 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C3DD61065670 for ; Wed, 27 Feb 2008 19:02:14 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from speedfactory.net (mail.speedfactory.net [66.23.216.219]) by mx1.freebsd.org (Postfix) with ESMTP id 453638FC18 for ; Wed, 27 Feb 2008 19:02:09 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (unverified [66.23.211.162]) by speedfactory.net (SurgeMail 3.8s) with ESMTP id 233603361-1834499 for multiple; Wed, 27 Feb 2008 13:59:59 -0500 Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m1RJ1vaB035481; Wed, 27 Feb 2008 14:01:57 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Garrett Wollman Date: Wed, 27 Feb 2008 13:57:29 -0500 User-Agent: KMail/1.9.7 References: <200802262251.m1QMp7bV021709@hergotha.csail.mit.edu> <200802271134.04166.jhb@freebsd.org> <18373.45558.444085.196189@hergotha.csail.mit.edu> In-Reply-To: <18373.45558.444085.196189@hergotha.csail.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200802271357.29188.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Wed, 27 Feb 2008 14:01:57 -0500 (EST) X-Virus-Scanned: ClamAV 0.91.2/6010/Wed Feb 27 07:54:14 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: arch@freebsd.org Subject: Re: Cleaning up FILE in stdio.. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Feb 2008 19:02:14 -0000 On Wednesday 27 February 2008 01:54:46 pm Garrett Wollman wrote: > < said: > > > I avoided EMFILE in all 3 cases as it struck me as being not really true (an > > app would find the rlimit higher than the current fd for example). Also, > > EMFILE doesn't really make sense from fdopen() at all. You've already opened > > the fd, so you know you can't run out of fd's. > > [EMFILE] is does not imply that you have run out of fds. POSIX > says (for fdopen()): > > The fdopen( ) function may fail if: > [EBADF] The fildes argument is not a valid file descriptor. > [EINVAL] The mode argument is not a valid mode. > [EMFILE] {FOPEN_MAX} streams are currently open in the > calling process. > [EMFILE] {STREAM_MAX} streams are currently open in the > calling process. > [ENOMEM] Insufficient space to allocate a buffer. > > My change to sysconf() causes {STREAM_MAX} to be clamped at > {SHRT_MAX}, so a user calling sysconf(_PC_STREAM_MAX) or > $(getconf STREAM_MAX) will see a different value from the resource > limit and understand that there is a limit (even if it's not quite on > the number of streams). > > For fopen(), the errors are defined as follows: > > "shall fail": > [EMFILE] {OPEN_MAX} file descriptors are currently open in the calling > process. > [ENFILE] The maximum allowable number of files is currently open in > the system. > > "may fail": > [EINVAL] The value of the mode argument is not valid. > [EMFILE] {FOPEN_MAX} streams are currently open in the calling > process. > [EMFILE] {STREAM_MAX} streams are currently open in the calling > process. > > The other possibility would be [EOVERFLOW], which is defined as: > > [EOVERFLOW] The named file is a regular file and the size of the file > cannot be represented correctly in an object of type off_t. > > But I truly believe that [EMFILE] is the best option. Ok. I was going based on our manpages, but I will happily use EMFILE instead given this. I will commit the temp fix today so we can MFC it. -- John Baldwin