[PATCH] D28854: raw_fd_ostream: Make file handles non-inheritable by default

Pavel Labath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 08:20:49 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL292401: raw_fd_ostream: Make file handles non-inheritable by default (authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D28854?vs=84833&id=84839#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28854

Files:
  llvm/trunk/lib/Support/Unix/Path.inc


Index: llvm/trunk/lib/Support/Unix/Path.inc
===================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc
+++ llvm/trunk/lib/Support/Unix/Path.inc
@@ -577,7 +577,7 @@
                                 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 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28854.84839.patch
Type: text/x-patch
Size: 874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170118/1042e1f0/attachment.bin>


More information about the llvm-commits mailing list