summaryrefslogtreecommitdiff
path: root/lib/libc/sys/accept.2
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2011-06-26 16:42:39 +0000
committerchristos <christos@NetBSD.org>2011-06-26 16:42:39 +0000
commitbbeb5403be5330b145ad01ccdbfa305d3bf8a76d (patch)
treed1be829e69cabc22b138aada13975946ca6ac102 /lib/libc/sys/accept.2
parent8b2572853f09a752d637652a9e7abb15ea88c254 (diff)
* Arrange for interfaces that create new file descriptors to be able to
set close-on-exec on creation (http://udrepper.livejournal.com/20407.html). - Add F_DUPFD_CLOEXEC to fcntl(2). - Add MSG_CMSG_CLOEXEC to recvmsg(2) for unix file descriptor passing. - Add dup3(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK. - Add pipe2(2) syscall with a flags argument for O_CLOEXEC, O_NONBLOCK. - Add flags SOCK_CLOEXEC, SOCK_NONBLOCK to the socket type parameter for socket(2) and socketpair(2). - Add new paccept(2) syscall that takes an additional sigset_t to alter the sigmask temporarily and a flags argument to set SOCK_CLOEXEC, SOCK_NONBLOCK. - Add new mode character 'e' to fopen(3) and popen(3) to open pipes and file descriptors for close on exec. - Add new kqueue1(2) syscall with a new flags argument to open the kqueue file descriptor with O_CLOEXEC, O_NONBLOCK. * Fix the system calls that take socklen_t arguments to actually do so. * Don't include userland header files (signal.h) from system header files (rump_syscallargs.h). * Bump libc version for the new syscalls.
Diffstat (limited to 'lib/libc/sys/accept.2')
-rw-r--r--lib/libc/sys/accept.246
1 files changed, 41 insertions, 5 deletions
diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2
index 9c7ea975d5b..d9b02af6cdd 100644
--- a/lib/libc/sys/accept.2
+++ b/lib/libc/sys/accept.2
@@ -1,4 +1,4 @@
-.\" $NetBSD: accept.2,v 1.26 2011/06/02 01:04:18 yamt Exp $
+.\" $NetBSD: accept.2,v 1.27 2011/06/26 16:42:41 christos Exp $
.\"
.\" Copyright (c) 1983, 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -33,7 +33,8 @@
.Dt ACCEPT 2
.Os
.Sh NAME
-.Nm accept
+.Nm accept ,
+.Nm paccept
.Nd accept a connection on a socket
.Sh LIBRARY
.Lb libc
@@ -41,6 +42,8 @@
.In sys/socket.h
.Ft int
.Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen"
+.Ft int
+.Fn paccept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "const sigset_t * restrict sigmask" "int flags"
.Sh DESCRIPTION
The argument
.Fa s
@@ -131,12 +134,41 @@ by issuing a
call with providing only the control information,
or by calling
.Xr setsockopt 2 .
+.Pp
+The
+.Fn paccept
+function behaves exactly like
+.Fn accept ,
+but it also allows to set the following
+.Fa flags
+on the returned file descriptor:
+.Bl -column SOCK_NONBLOCK -offset indent
+.It Dv SOCK_CLOEXEC
+Set the close on exec property.
+.It Dv SOCK_NONBLOCK
+Sets non-blocking I/O.
+.El
+.Pp
+It can also temporarily replace the signal mask of the calling thread if
+.Fa sigmask
+is a non-null pointer, then the
+.Fn paccept
+function shall replace the signal mask of the caller by the set of
+signals pointed to by
+.Fa sigmask
+before waiting for a connection, and shall restore the signal mask
+of the calling thread before returning.
.Sh RETURN VALUES
-The call returns \-1 on error.
-If it succeeds, it returns a non-negative
+The
+.Fn accept
+and
+.Fn paccept calls return \-1 on error.
+If they succeed, they return a non-negative
integer that is a descriptor for the accepted socket.
.Sh COMPATIBILITY
-This implementation makes the new file descriptor inherit file flags
+The
+.Fn accept
+implementation makes the new file descriptor inherit file flags
(like
.Dv O_NONBLOCK )
from the listening socket.
@@ -192,3 +224,7 @@ The
.Fn accept
function appeared in
.Bx 4.2 .
+The
+.Fn pselect
+function is inspired from Linux and appeared in
+.Nx 6.0 .