summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2013-01-06 06:04:58 -0500
committerColin Walters <walters@verbum.org>2013-01-06 06:04:58 -0500
commitc98f7e4604d50837074585368b6913b93d3af265 (patch)
treec3b3666c935a6726a3898fa9591308053a995847
parenta2519612547354033f0d513a174f336896776fa8 (diff)
downloadlibgsystem-c98f7e4604d50837074585368b6913b93d3af265.tar.gz
fileutils: Handle EINTR around open()
Just noticed via code inspection.
-rw-r--r--gsystem-file-utils.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index 312ea2f..93a3d68 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -49,18 +49,28 @@ close_nointr_noerror (int fd)
}
static int
+open_nointr (const char *path, int flags, mode_t mode)
+{
+ int res;
+ do
+ res = open (path, flags, mode);
+ while (G_UNLIKELY (res != 0 && errno == EINTR));
+ return res;
+}
+
+static int
_open_fd_noatime (const char *path)
{
int fd;
#ifdef O_NOATIME
- fd = g_open (path, O_RDONLY | O_NOATIME, 0);
+ fd = open_nointr (path, O_RDONLY | O_NOATIME, 0);
/* Only the owner or superuser may use O_NOATIME; so we may get
* EPERM. EINVAL may happen if the kernel is really old...
*/
if (fd == -1 && (errno == EPERM || errno == EINVAL))
#endif
- fd = g_open (path, O_RDONLY, 0);
+ fd = open_nointr (path, O_RDONLY, 0);
return fd;
}
@@ -254,6 +264,7 @@ get_default_tmp_prefix (void)
return tmpprefix;
}
+
static char *
gen_tmp_name (const char *prefix,
const char *suffix)