From 8a7508ed40ef04466a66a7ae10125b25c598b715 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 17 Jan 2020 22:02:48 +0100 Subject: [PATCH] utils: retry on temporary close failures Signed-off-by: Giuseppe Scrivano --- utils.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 48ac146..611a46c 100644 --- a/utils.c +++ b/utils.c @@ -23,6 +23,15 @@ #include #include +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(expression) \ + (__extension__ \ + ({ long int __result; \ + do __result = (long int) (expression); \ + while (__result == -1L && errno == EINTR); \ + __result; })) +#endif + int file_exists_at (int dirfd, const char *pathname) { @@ -120,7 +129,7 @@ cleanup_closep (void *p) { int *pp = p; if (*pp >= 0) - close (*pp); + TEMP_FAILURE_RETRY (close (*pp)); } void