os: define SOCK_CLOEXEC on Linux

If it's not already defined, and we are on Linux, #define it. This gets
rid of a load of #ifdefs. This should also allow to use it when the
kernel supports it, but the libc does not define it.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
Pekka Paalanen 2012-04-23 12:10:45 +03:00
parent 1f827a4776
commit 3b29783dc8
3 changed files with 14 additions and 9 deletions

View file

@ -55,13 +55,11 @@ wl_os_socket_cloexec(int domain, int type, int protocol)
{
int fd;
#ifdef SOCK_CLOEXEC
fd = socket(domain, type | SOCK_CLOEXEC, protocol);
if (fd >= 0)
return fd;
if (errno != EINVAL)
return -1;
#endif
fd = socket(domain, type, protocol);
return set_cloexec_or_close(fd);