Support: Don't call close again if we get EINTR
[oota-llvm.git] / include / llvm / Support / Process.h
index bb7467bfc83ee13ed543e9cf178a72be0b0611ae..861667927d8a9bb8dc9587525c9f1b2625b8ad98 100644 (file)
@@ -192,6 +192,15 @@ public:
   // components should not call this.
   static std::error_code FixupStandardFileDescriptors();
 
+  // This function safely closes a file descriptor.  It is not safe to retry
+  // close(2) when it returns with errno equivalent to EINTR; this is because
+  // *nixen cannot agree if the file descriptor is, in fact, closed when this
+  // occurs.
+  //
+  // N.B. Some operating systems, due to thread cancellation, cannot properly
+  // guarantee that it will or will not be closed one way or the other!
+  static std::error_code SafelyCloseFileDescriptor(int FD);
+
   /// This function determines if the standard input is connected directly
   /// to a user's input (keyboard probably), rather than coming from a file
   /// or pipe.