[PATCH] D31505: Do not close STD* descriptors

Yaron Keren via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 30 12:27:31 PDT 2017


yaron.keren created this revision.

Following r297661, disable dup workaround to disable duplicate STDOUT fd closing and instead directly prevent closing of STD* file descriptors.


Repository:
  rL LLVM

https://reviews.llvm.org/D31505

Files:
  lib/Support/raw_ostream.cpp


Index: lib/Support/raw_ostream.cpp
===================================================================
--- lib/Support/raw_ostream.cpp
+++ lib/Support/raw_ostream.cpp
@@ -473,7 +473,7 @@
     // possible.
     if (!(Flags & sys::fs::F_Text))
       sys::ChangeStdoutToBinary();
-    return dup(STDOUT_FILENO);
+    return STDOUT_FILENO;
   }
 
   int FD;
@@ -497,6 +497,8 @@
     ShouldClose = false;
     return;
   }
+  if (FD <= STDERR_FILENO)
+    ShouldClose = false;
 
   // Get the starting position.
   off_t loc = ::lseek(FD, 0, SEEK_CUR);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31505.93521.patch
Type: text/x-patch
Size: 549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170330/051bfc70/attachment.bin>


More information about the llvm-commits mailing list