diff options
author | asmodai <asmodai@FreeBSD.org> | 2002-04-13 10:16:53 +0000 |
---|---|---|
committer | asmodai <asmodai@FreeBSD.org> | 2002-04-13 10:16:53 +0000 |
commit | 4d94ee39e68fce6f6387a3cfc3b8ef91a146d899 (patch) | |
tree | 61a539046bb25148bb08720dc78daf3c2f12d3c2 | |
parent | e2a368995a1373f9bd14d34997f119346f009a72 (diff) | |
download | FreeBSD-src-4d94ee39e68fce6f6387a3cfc3b8ef91a146d899.zip FreeBSD-src-4d94ee39e68fce6f6387a3cfc3b8ef91a146d899.tar.gz |
Use the correct macros for F_SETFD/F_GETFD instead of magic numbers.
Reflect that fact in the manual page.
PR: 12723
Submitted by: Peter Jeremy <peter.jeremy@alcatel.com.au>
Approved by: bde
MFC after: 2 weeks
-rw-r--r-- | lib/libc/sys/fcntl.2 | 16 | ||||
-rw-r--r-- | sys/kern/kern_descrip.c | 5 |
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2 index 41184b3..e6ddee9 100644 --- a/lib/libc/sys/fcntl.2 +++ b/lib/libc/sys/fcntl.2 @@ -82,8 +82,12 @@ system calls. .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 @@ is ignored). .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 diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 034aba9..9f017301 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -287,12 +287,13 @@ fcntl(td, uap) break; case F_GETFD: - td->td_retval[0] = *pop & 1; + td->td_retval[0] = (*pop & UF_EXCLOSE) ? FD_CLOEXEC : 0; FILEDESC_UNLOCK(fdp); break; case F_SETFD: - *pop = (*pop &~ 1) | (uap->arg & 1); + *pop = (*pop &~ UF_EXCLOSE) | + (uap->arg & FD_CLOEXEC ? UF_EXCLOSE : 0); FILEDESC_UNLOCK(fdp); break; |