Index: lib/Support/Unix/Path.inc =================================================================== --- lib/Support/Unix/Path.inc +++ lib/Support/Unix/Path.inc @@ -577,7 +577,11 @@ SmallVectorImpl *RealPath) { SmallString<128> Storage; StringRef P = Name.toNullTerminatedStringRef(Storage); - while ((ResultFD = open(P.begin(), O_RDONLY | O_CLOEXEC)) < 0) { + int OpenFlags = O_RDONLY; +#ifdef O_CLOEXEC + OpenFlags |= O_CLOEXEC; +#endif + while ((ResultFD = open(P.begin(), OpenFlags)) < 0) { if (errno != EINTR) return std::error_code(errno, std::generic_category()); } @@ -614,7 +618,11 @@ assert((!(Flags & sys::fs::F_Excl) || !(Flags & sys::fs::F_Append)) && "Cannot specify both 'excl' and 'append' file creation flags!"); - int OpenFlags = O_CREAT | O_CLOEXEC; + int OpenFlags = O_CREAT; + +#ifdef O_CLOEXEC + OpenFlags |= O_CLOEXEC; +#endif if (Flags & F_RW) OpenFlags |= O_RDWR;