Date: Wed, 19 Sep 2001 09:02:01 +1000 From: Peter Jeremy <peter.jeremy@alcatel.com.au> To: gnats-admin@FreeBSD.org, freebsd-bugs@FreeBSD.org Subject: Re: kern/12723: Unnecessary use of magic numbers in F_[SG]ETFD code Message-ID: <20010919090201.B4912@gsmx07.alcatel.com.au> In-Reply-To: <199907202330.QAA88579@freefall.freebsd.org>; from gnats-admin@FreeBSD.org on Wed, Jul 21, 1999 at 09:30:01AM %2B1000 References: <"99Jul21.090707est.40353"@border.alcanet.com.au> <199907202330.QAA88579@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010919090201.B4912>