Just because SOCK_CLOEXEC was defined at build time doesn't mean the
kernel we're running on supports it. So if socket() fails with EINVAL,
try again without the flag.
https://bugzilla.gnome.org/show_bug.cgi?id=624463
}
#ifdef SOCK_CLOEXEC
- native_type |= SOCK_CLOEXEC;
+ fd = socket (family, native_type | SOCK_CLOEXEC, protocol);
+ /* It's possible that libc has SOCK_CLOEXEC but the kernel does not */
+ if (fd < 0 && errno == EINVAL)
#endif
- fd = socket (family, native_type, protocol);
+ fd = socket (family, native_type, protocol);
if (fd < 0)
{