diff options
author | jilles <jilles@FreeBSD.org> | 2013-03-19 20:58:17 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-03-19 20:58:17 +0000 |
commit | c9066bd014b20089911abc91a8c87ef738498a28 (patch) | |
tree | 71ad20dc1a5c91d4fc411e2e04d96225b53fd904 /share | |
parent | 30ce276eca66462aa7b3385fa4f6daac2634fbcc (diff) | |
download | FreeBSD-src-c9066bd014b20089911abc91a8c87ef738498a28.zip FreeBSD-src-c9066bd014b20089911abc91a8c87ef738498a28.tar.gz |
Implement SOCK_CLOEXEC, SOCK_NONBLOCK and MSG_CMSG_CLOEXEC.
This change allows creating file descriptors with close-on-exec set in some
situations. SOCK_CLOEXEC and SOCK_NONBLOCK can be OR'ed in socket() and
socketpair()'s type parameter, and MSG_CMSG_CLOEXEC to recvmsg() makes file
descriptors (SCM_RIGHTS) atomically close-on-exec.
The numerical values for SOCK_CLOEXEC and SOCK_NONBLOCK are as in NetBSD.
MSG_CMSG_CLOEXEC is the first free bit for MSG_*.
The SOCK_* flags are not passed to MAC because this may cause incorrect
failures and can be done later via fcntl() anyway. On the other hand, audit
is expected to cope with the new flags.
For MSG_CMSG_CLOEXEC, unp_externalize() is extended to take a flags
argument.
Reviewed by: kib
Diffstat (limited to 'share')
-rw-r--r-- | share/man/man4/unix.4 | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/share/man/man4/unix.4 b/share/man/man4/unix.4 index 363f185..c53cc42 100644 --- a/share/man/man4/unix.4 +++ b/share/man/man4/unix.4 @@ -32,7 +32,7 @@ .\" @(#)unix.4 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd November 16, 2012 +.Dd March 19, 2013 .Dt UNIX 4 .Os .Sh NAME @@ -153,13 +153,15 @@ plus the size of the array of file descriptors. .Pp The received descriptor is a .Em duplicate -of the sender's descriptor, as if it were created with a call to -.Xr dup 2 . -Per-process descriptor flags, set with -.Xr fcntl 2 , -are -.Em not -passed to a receiver. +of the sender's descriptor, as if it were created via +.Li dup(fd) +or +.Li fcntl(fd, F_DUPFD_CLOEXEC, 0) +depending on whether +.Dv MSG_CMSG_CLOEXEC +is passed in the +.Xr recvmsg 2 +call. Descriptors that are awaiting delivery, or that are purposely not received, are automatically closed by the system when the destination socket is closed. |