Index: runtime/bin/fdutils_android.cc |
diff --git a/runtime/bin/fdutils_android.cc b/runtime/bin/fdutils_android.cc |
index 7e8f72b9097d64adfd0b05a0be57d6831c027196..8d946e68677b1d5a86e41fbb3ad89a8c7cb20f41 100644 |
--- a/runtime/bin/fdutils_android.cc |
+++ b/runtime/bin/fdutils_android.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)); |