From owner-freebsd-current@FreeBSD.ORG Sat Nov 29 21:41:08 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C452416A4CE; Sat, 29 Nov 2003 21:41:08 -0800 (PST) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id D1F5843FE3; Sat, 29 Nov 2003 21:41:07 -0800 (PST) (envelope-from eischen@vigrid.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.10/8.12.1) with ESMTP id hAU5f61G007613; Sun, 30 Nov 2003 00:41:07 -0500 (EST) Date: Sun, 30 Nov 2003 00:41:06 -0500 (EST) From: Daniel Eischen X-Sender: eischen@pcnet5.pcnet.com To: Alfred Perlstein In-Reply-To: <20031129234834.GY35957@elvis.mu.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: re@freebsd.org cc: current@freebsd.org Subject: Re: [PATCH] please review. file descriptor passing for libc_r. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Nov 2003 05:41:08 -0000 On Sat, 29 Nov 2003, Alfred Perlstein wrote: > * Daniel Eischen [031129 14:57] wrote: > > > > > > What do you suggest we do? > > > > Just close the file: > > > > if ((fd < 0) || (fd >= _thread_dtablesize) || > > (fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) { > > /* > > * Don't allow silly programs to close the kernel pipe > > * and non-active descriptors. > > */ > > errno = EBADF; > > ret = -1; > > } > > else if (_thread_fd_table[fd] == NULL) > > ret = __sys_close(fd); > > else { > > ... > > } > > So remove the check? do you approve? does re@ approve? You should just call close() if the fd has not been initialized. Index: uthread_close.c =================================================================== RCS file: /opt/FreeBSD/cvs/src/lib/libc_r/uthread/uthread_close.c,v retrieving revision 1.16 diff -u -r1.16 uthread_close.c --- uthread_close.c 9 Jun 2003 16:45:37 -0000 1.16 +++ uthread_close.c 30 Nov 2003 09:05:52 -0000 @@ -50,8 +50,7 @@ struct fd_table_entry *entry; if ((fd < 0) || (fd >= _thread_dtablesize) || - (fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1]) || - (_thread_fd_table[fd] == NULL)) { + (fd == _thread_kern_pipe[0]) || (fd == _thread_kern_pipe[1])) { /* * Don't allow silly programs to close the kernel pipe * and non-active descriptors. @@ -59,6 +58,8 @@ errno = EBADF; ret = -1; } + else if (_thread_fd_table[fd] == NULL) + ret = __sys_close(fd); /* * Lock the file descriptor while the file is closed and get * the file descriptor status: -- Dan Eischen