rewrite socket to rk_socket of there is SOCK_CLOEXEC and there is linux, prompted by Harald Barth
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user