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
parent
fa6d63c936
commit
118bee287c
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue