1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:47:45 +00:00

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.
This commit is contained in:
Gunnar Beutner 2021-05-16 19:56:11 +02:00 committed by Andreas Kling
parent 529f605ac8
commit 89956cb0d6
7 changed files with 49 additions and 18 deletions

View file

@ -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, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

View file

@ -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);