diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-05-16 19:56:11 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-17 13:32:19 +0200 |
commit | 89956cb0d66f24bfcee312dcd35f78b5dbc9e1b9 (patch) | |
tree | dd7f38132b4cb91410271b4948cdfe99d28778d0 /Userland/Libraries/LibC | |
parent | 529f605ac801a541b1206ce06d497f8835ca7412 (diff) | |
download | serenity-89956cb0d66f24bfcee312dcd35f78b5dbc9e1b9.zip |
Kernel+Userspace: Implement the accept4() system call
Unlike accept() the new accept4() system call lets the caller specify
flags for the newly accepted socket file descriptor, such as
SOCK_CLOEXEC and SOCK_NONBLOCK.
Diffstat (limited to 'Userland/Libraries/LibC')
-rw-r--r-- | Userland/Libraries/LibC/sys/socket.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibC/sys/socket.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibC/sys/socket.cpp b/Userland/Libraries/LibC/sys/socket.cpp index 96211141b1..ba9cdd38ec 100644 --- a/Userland/Libraries/LibC/sys/socket.cpp +++ b/Userland/Libraries/LibC/sys/socket.cpp @@ -34,7 +34,13 @@ int listen(int sockfd, int backlog) int accept(int sockfd, sockaddr* addr, socklen_t* addrlen) { - int rc = syscall(SC_accept, sockfd, addr, addrlen); + return accept4(sockfd, addr, addrlen, 0); +} + +int accept4(int sockfd, sockaddr* addr, socklen_t* addrlen, int flags) +{ + Syscall::SC_accept4_params params { sockfd, addr, addrlen, flags }; + int rc = syscall(SC_accept4, ¶ms); __RETURN_WITH_ERRNO(rc, rc, -1); } diff --git a/Userland/Libraries/LibC/sys/socket.h b/Userland/Libraries/LibC/sys/socket.h index 44b673546d..0ff9aaff14 100644 --- a/Userland/Libraries/LibC/sys/socket.h +++ b/Userland/Libraries/LibC/sys/socket.h @@ -127,6 +127,7 @@ int socket(int domain, int type, int protocol); int bind(int sockfd, const struct sockaddr* addr, socklen_t); int listen(int sockfd, int backlog); int accept(int sockfd, struct sockaddr*, socklen_t*); +int accept4(int sockfd, struct sockaddr*, socklen_t*, int); int connect(int sockfd, const struct sockaddr*, socklen_t); int shutdown(int sockfd, int how); ssize_t send(int sockfd, const void*, size_t, int flags); |