Fix inconsistencies in accept4.c

Fix inconsistencies in accept4.c. If the underlying accept() fails the shim returns the listening socket s instead of −1.
This commit is contained in:
imorgenstern
2025-08-28 13:42:04 +02:00
committed by GitHub
parent cf1a8cf5ba
commit d7a9ca6d2f

View File

@@ -6,10 +6,10 @@ accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
{
int rets = accept(s, addr, addrlen);
if (rets == -1)
return s;
return rets;
if (flags & SOCK_CLOEXEC) {
flags = fcntl(s, F_GETFD);
flags = fcntl(rets, F_GETFD);
fcntl(rets, F_SETFD, flags | FD_CLOEXEC);
}