libbase: realpath is wrapped with TEMP_FAILURE_RETRY
Although man page for realpath doesn't say so, the bionic
implementation of realpath may exit with error code
EINTR. In such cases, retry.
Test: boots (sanity)
Change-Id: Ic5feb7152374a81bd2f475ad74c4bc8c3afb3a20
diff --git a/base/file.cpp b/base/file.cpp
index 2f4a517..adc8984 100644
--- a/base/file.cpp
+++ b/base/file.cpp
@@ -385,7 +385,12 @@
bool Realpath(const std::string& path, std::string* result) {
result->clear();
- char* realpath_buf = realpath(path.c_str(), nullptr);
+ // realpath may exit with EINTR. Retry if so.
+ char* realpath_buf = nullptr;
+ do {
+ realpath_buf = realpath(path.c_str(), nullptr);
+ } while (realpath_buf == nullptr && errno == EINTR);
+
if (realpath_buf == nullptr) {
return false;
}