mirror of
https://github.com/libressl/portable.git
synced 2026-01-17 21:51:17 +01:00
Fix inconsistencies in accept4.c. If the underlying accept() fails the shim returns the listening socket s instead of −1.
18 lines
315 B
C
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;
|
|
}
|