force socket descriptor to have SOCK_CLOEXEC set
| 3380 | |
| 3381 | // force socket descriptor to have SOCK_CLOEXEC set |
| 3382 | SOCKET socket(int domain, int type, int protocol) |
| 3383 | { |
| 3384 | #ifdef WIN_NT |
| 3385 | return ::socket(domain, type, protocol); |
| 3386 | #else |
| 3387 | int fd; |
| 3388 | #if HAVE_DECL_SOCK_CLOEXEC |
| 3389 | do { |
| 3390 | fd = ::socket(domain, type | SOCK_CLOEXEC, protocol); |
| 3391 | } while (fd < 0 && SYSCALL_INTERRUPTED(errno)); |
| 3392 | |
| 3393 | if (fd < 0 && errno == EINVAL) // probably SOCK_CLOEXEC not accepted |
| 3394 | #endif |
| 3395 | { |
| 3396 | do { |
| 3397 | fd = ::socket(domain, type, protocol); |
| 3398 | } while (fd < 0 && SYSCALL_INTERRUPTED(errno)); |
| 3399 | } |
| 3400 | |
| 3401 | setCloseOnExec(fd); |
| 3402 | return fd; |
| 3403 | #endif |
| 3404 | } |
| 3405 | |
| 3406 | // force socket descriptor to have SOCK_CLOEXEC set |
| 3407 | SOCKET accept(SOCKET sockfd, struct sockaddr* addr, socklen_t* addrlen) |
no test coverage detected