From owner-freebsd-bugs Tue Sep 18 16: 2:12 2001 Delivered-To: freebsd-bugs@freebsd.org Received: from netau1.alcanet.com.au (ntp.alcanet.com.au [203.62.196.27]) by hub.freebsd.org (Postfix) with ESMTP id 5B00237B409; Tue, 18 Sep 2001 16:02:06 -0700 (PDT) Received: from mfg1.cim.alcatel.com.au (mfg1.cim.alcatel.com.au [139.188.23.1]) by netau1.alcanet.com.au (8.9.3 (PHNE_22672)/8.9.3) with ESMTP id JAA18512; Wed, 19 Sep 2001 09:02:05 +1000 (EST) Received: from gsmx07.alcatel.com.au by cim.alcatel.com.au (PMDF V5.2-32 #37640) with ESMTP id <01K8IKJMUZDSVMF4VB@cim.alcatel.com.au>; Wed, 19 Sep 2001 09:02:03 +1000 Received: (from jeremyp@localhost) by gsmx07.alcatel.com.au (8.11.1/8.11.1) id f8IN22N05073; Wed, 19 Sep 2001 09:02:02 +1000 (EST envelope-from jeremyp) Content-return: prohibited Date: Wed, 19 Sep 2001 09:02:01 +1000 From: Peter Jeremy Subject: Re: kern/12723: Unnecessary use of magic numbers in F_[SG]ETFD code In-reply-to: <199907202330.QAA88579@freefall.freebsd.org>; from gnats-admin@FreeBSD.org on Wed, Jul 21, 1999 at 09:30:01AM +1000 To: gnats-admin@FreeBSD.org, freebsd-bugs@FreeBSD.org Message-id: <20010919090201.B4912@gsmx07.alcatel.com.au> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-disposition: inline User-Agent: Mutt/1.2.5i References: <"99Jul21.090707est.40353"@border.alcanet.com.au> <199907202330.QAA88579@freefall.freebsd.org> Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Updated patch following KSE commit. Note that whilst this patch compiles, I haven't tested it. Index: src/lib/libc/sys/fcntl.2 =================================================================== RCS file: /home/CVSROOT/src/lib/libc/sys/fcntl.2,v retrieving revision 1.33 diff -u -r1.33 fcntl.2 --- src/lib/libc/sys/fcntl.2 2001/08/27 08:37:35 1.33 +++ src/lib/libc/sys/fcntl.2 2001/08/28 14:49:28 @@ -82,8 +82,12 @@ .El .It Dv F_GETFD Get the close-on-exec flag associated with the file descriptor -.Fa fd . -If the low-order bit of the returned value is 0, +.Fa fd +as +.Dv FD_CLOEXEC . +If the returned value anded with +.Dv FD_CLOEXEC +is 0, the file will remain open across .Fn exec , otherwise the file will be closed upon execution of @@ -93,9 +97,13 @@ .It Dv F_SETFD Set the close-on-exec flag associated with .Fa fd -to the low order bit of +to +.Fa arg , +where .Fa arg -(0 or 1 as above). +is either 0 or +.Dv FD_CLOEXEC , +as described above. .It Dv F_GETFL Get descriptor status flags, as described below .Fa ( arg Index: src/sys/kern/kern_descrip.c =================================================================== RCS file: /home/CVSROOT/src/sys/kern/kern_descrip.c,v retrieving revision 1.108 diff -u -r1.108 kern_descrip.c --- src/sys/kern/kern_descrip.c 2001/09/12 20:26:57 1.108 +++ src/sys/kern/kern_descrip.c 2001/09/16 20:50:25 @@ -278,11 +278,12 @@ break; case F_GETFD: - td->td_retval[0] = *pop & 1; + td->td_retval[0] = (*pop & UF_EXCLOSE) ? FD_CLOEXEC : 0; break; case F_SETFD: - *pop = (*pop &~ 1) | (uap->arg & 1); + *pop = (*pop &~ UF_EXCLOSE) | + (uap->arg & FD_CLOEXEC ? UF_EXCLOSE : 0); break; case F_GETFL: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message