Wrap use of SOCK_CLOEXEC with __linux__

This guards against the case where your clibrary defines SOCK_CLOEXEC
but the underlying network library does not support it.
libnfs-4.0.0-vitalif
Anna Lyons 2018-07-03 09:08:22 +10:00
parent fa6d63c936
commit 118bee287c
1 changed files with 3 additions and 1 deletions

View File

@ -93,12 +93,14 @@ static int
create_socket(int domain, int type, int protocol)
{
#ifdef SOCK_CLOEXEC
/* Linux-specific extension (since 2.6.27): set the
#ifdef __linux__
/* Linux-specific extension (since 2.6.27): set the
close-on-exec flag on all sockets to avoid leaking file
descriptors to child processes */
int fd = socket(domain, type|SOCK_CLOEXEC, protocol);
if (fd >= 0 || errno != EINVAL)
return fd;
#endif
#endif
return socket(domain, type, protocol);