summaryrefslogtreecommitdiffstats
path: root/include/cutils
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-09-13 14:47:23 -0700
committerJeff Sharkey <jsharkey@android.com>2012-09-13 15:02:53 -0700
commitddb173394430a7b55b0c24896a843556f5f8de7a (patch)
tree68448c53c7179d50195488b3ad291a4c100489d0 /include/cutils
parent0f5e303c6a88c63fc5a4d325ab675af7ed57b777 (diff)
downloadsystem_core-ddb173394430a7b55b0c24896a843556f5f8de7a.zip
system_core-ddb173394430a7b55b0c24896a843556f5f8de7a.tar.gz
system_core-ddb173394430a7b55b0c24896a843556f5f8de7a.tar.bz2
Wrap system calls in TEMP_FAILURE_RETRY.
fs_prepare_dir() is used heavily during Zygote init, and can easily run into EINTR. Bug: 7151474 Change-Id: I7aac43a43483d55db47ca20456fff68ce51bbc46
Diffstat (limited to 'include/cutils')
-rw-r--r--include/cutils/fs.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/cutils/fs.h b/include/cutils/fs.h
index 04c8839..fd5296b 100644
--- a/include/cutils/fs.h
+++ b/include/cutils/fs.h
@@ -19,6 +19,21 @@
#include <sys/types.h>
+/*
+ * TEMP_FAILURE_RETRY is defined by some, but not all, versions of
+ * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's
+ * not already defined, then define it here.
+ */
+#ifndef TEMP_FAILURE_RETRY
+/* Used to retry syscalls that can return EINTR. */
+#define TEMP_FAILURE_RETRY(exp) ({ \
+ typeof (exp) _rc; \
+ do { \
+ _rc = (exp); \
+ } while (_rc == -1 && errno == EINTR); \
+ _rc; })
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif