utils: retry on temporary close failures

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2020-01-17 22:02:48 +01:00
parent d4a957dea9
commit 8a7508ed40
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

11
utils.c
View File

@ -23,6 +23,15 @@
#include <string.h>
#include <sys/sysmacros.h>
#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