rewrite socket to rk_socket of there is SOCK_CLOEXEC and there is linux, prompted by Harald Barth

This commit is contained in:
Love Hornquist Astrand
2010-01-25 23:01:18 -08:00
parent deee0bbad9
commit 2fbdb6a514
2 changed files with 25 additions and 0 deletions

View File

@@ -315,3 +315,23 @@ socket_to_fd(rk_socket_t sock, int flags)
return _open_osfhandle((intptr_t) sock, flags);
#endif
}
#ifndef HEIMAL_SMALLER
int rk_socket(int, int, int);
int
rk_socket(int domain, int type, int protocol)
{
int s;
s = socket (domain, type, protocol);
#ifdef SOCK_CLOEXEC
if ((SOCK_CLOEXEC & protocol) && s < 0 && errno == EINVAL) {
protocol &= ~SOCK_CLOEXEC;
s = socket (domain, type, protocol);
}
#endif
return s;
}
#endif