summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys/accept.2
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/sys/accept.2')
-rw-r--r--lib/libc/sys/accept.245
1 files changed, 42 insertions, 3 deletions
diff --git a/lib/libc/sys/accept.2 b/lib/libc/sys/accept.2
index d27bce3..8353ecf 100644
--- a/lib/libc/sys/accept.2
+++ b/lib/libc/sys/accept.2
@@ -41,6 +41,8 @@
.In sys/socket.h
.Ft int
.Fn accept "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen"
+.Ft int
+.Fn accept4 "int s" "struct sockaddr * restrict addr" "socklen_t * restrict addrlen" "int flags"
.Sh DESCRIPTION
The argument
.Fa s
@@ -66,6 +68,26 @@ and
signals from the original socket
.Fa s .
.Pp
+The
+.Fn accept4
+system call is similar,
+but the
+.Dv O_NONBLOCK
+property of the new socket is instead determined by the
+.Dv SOCK_NONBLOCK
+flag in the
+.Fa flags
+argument,
+the
+.Dv O_ASYNC
+property is cleared,
+the signal destination is cleared
+and the close-on-exec flag on the new file descriptor can be set via the
+.Dv SOCK_CLOEXEC
+flag in the
+.Fa flags
+argument.
+.Pp
If no pending connections are
present on the queue, and the original socket
is not marked as non-blocking,
@@ -141,13 +163,15 @@ properties and the signal destination being inherited,
but should set them explicitly using
.Xr fcntl 2 .
.Sh RETURN VALUES
-The call returns \-1 on error.
-If it succeeds, it returns a non-negative
+These calls return \-1 on error.
+If they succeed, they return a non-negative
integer that is a descriptor for the accepted socket.
.Sh ERRORS
The
.Fn accept
-system call will fail if:
+and
+.Fn accept4
+system calls will fail if:
.Bl -tag -width Er
.It Bq Er EBADF
The descriptor is invalid.
@@ -176,6 +200,16 @@ are present to be accepted.
A connection arrived, but it was closed while waiting
on the listen queue.
.El
+.Pp
+The
+.Fn accept4
+system call will also fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa flags
+argument is invalid.
+.El
.Sh SEE ALSO
.Xr bind 2 ,
.Xr connect 2 ,
@@ -190,3 +224,8 @@ The
.Fn accept
system call appeared in
.Bx 4.2 .
+.Pp
+The
+.Fn accept4
+system call appeared in
+.Fx 10.0 .
OpenPOWER on IntegriCloud