allow nc to build on linux and os x

This commit is contained in:
Brent Cook
2015-09-13 11:56:41 -05:00
parent 627b0261a8
commit 8c90be2a29
16 changed files with 604 additions and 21 deletions

17
apps/nc/compat/accept4.c Normal file
View File

@@ -0,0 +1,17 @@
#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 s;
if (flags & SOCK_CLOEXEC) {
flags = fcntl(s, F_GETFD);
fcntl(rets, F_SETFD, flags | FD_CLOEXEC);
}
return rets;
}