[llvm] r292401 - raw_fd_ostream: Make file handles non-inheritable by default
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 07:46:50 PST 2017
Author: labath
Date: Wed Jan 18 09:46:50 2017
New Revision: 292401
URL: http://llvm.org/viewvc/llvm-project?rev=292401&view=rev
Log:
raw_fd_ostream: Make file handles non-inheritable by default
Summary:
This makes the file descriptors on unix platform non-inheritable (O_CLOEXEC).
There is no change in behavior on windows, as the handles were already
non-inheritable there.
Reviewers: rnk, rafael
Subscribers: llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D28854
Modified:
llvm/trunk/lib/Support/Unix/Path.inc
Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=292401&r1=292400&r2=292401&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Wed Jan 18 09:46:50 2017
@@ -577,7 +577,7 @@ std::error_code openFileForRead(const Tw
SmallVectorImpl<char> *RealPath) {
SmallString<128> Storage;
StringRef P = Name.toNullTerminatedStringRef(Storage);
- while ((ResultFD = open(P.begin(), O_RDONLY)) < 0) {
+ while ((ResultFD = open(P.begin(), O_RDONLY | O_CLOEXEC)) < 0) {
if (errno != EINTR)
return std::error_code(errno, std::generic_category());
}
@@ -614,7 +614,7 @@ std::error_code openFileForWrite(const T
assert((!(Flags & sys::fs::F_Excl) || !(Flags & sys::fs::F_Append)) &&
"Cannot specify both 'excl' and 'append' file creation flags!");
- int OpenFlags = O_CREAT;
+ int OpenFlags = O_CREAT | O_CLOEXEC;
if (Flags & F_RW)
OpenFlags |= O_RDWR;
More information about the llvm-commits
mailing list