Index: runtime/bin/fdutils_macos.cc |
diff --git a/runtime/bin/fdutils_macos.cc b/runtime/bin/fdutils_macos.cc |
index b9ea0493bd19793873ed51ff86bb8ce1529d37e0..92e63fcefd56882579cddc02c9e99d5d759cd0f3 100644 |
--- a/runtime/bin/fdutils_macos.cc |
+++ b/runtime/bin/fdutils_macos.cc |
@@ -10,6 +10,22 @@ |
#include "bin/fdutils.h" |
+bool FDUtils::SetCloseOnExec(intptr_t fd) { |
+ intptr_t status; |
+ status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD)); |
+ if (status < 0) { |
+ perror("fcntl F_GETFD failed"); |
+ return false; |
+ } |
+ status |= FD_CLOEXEC; |
+ if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, status)) < 0) { |
+ perror("fcntl F_SETFD failed"); |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+ |
static bool SetBlockingHelper(intptr_t fd, bool blocking) { |
intptr_t status; |
status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL)); |