Files
libressl/apps/nc/compat/accept4.c
imorgenstern d7a9ca6d2f 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.
2025-08-28 13:42:04 +02:00

18 lines
315 B
C

#include <sys/socket.h>
#include <fcntl.h>
int
accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags)
{
int rets = accept(s, addr, addrlen);
if (rets == -1)
return rets;
if (flags & SOCK_CLOEXEC) {
flags = fcntl(rets, F_GETFD);
fcntl(rets, F_SETFD, flags | FD_CLOEXEC);
}
return rets;
}