From 5f4cb8a24060da1bd60f0580848fa2e94ade3f0a Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Thu, 21 Mar 2019 15:20:53 -0700 Subject: [PATCH] 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 --- base/file.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/base/file.cpp b/base/file.cpp index 2f4a51758..adc898489 100644 --- a/base/file.cpp +++ b/base/file.cpp @@ -385,7 +385,12 @@ bool Readlink(const std::string& path, std::string* result) { 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; }