Merge pull request #260 from pingerino/sock_cloexec

Wrap use of SOCK_CLOEXEC with __linux__
libnfs-4.0.0-vitalif
Ronnie Sahlberg 2018-07-03 18:38:44 +10:00 committed by GitHub
commit 9b5bb0b2f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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);