mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
gstdio: Handle EINTR in g_fsync()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
84dd89242a
commit
926dfe5925
@ -1660,10 +1660,13 @@ g_freopen (const gchar *filename,
|
|||||||
* g_fsync:
|
* g_fsync:
|
||||||
* @fd: a file descriptor
|
* @fd: a file descriptor
|
||||||
*
|
*
|
||||||
* A wrapper for the POSIX fsync() function (_commit() on Windows).
|
* A wrapper for the POSIX `fsync()` function. On Windows, `_commit()` will be
|
||||||
* The fsync() function is used to synchronize a file's in-core
|
* used.
|
||||||
|
* The `fsync()` function is used to synchronize a file's in-core
|
||||||
* state with that of the disk.
|
* state with that of the disk.
|
||||||
*
|
*
|
||||||
|
* This wrapper will handle retrying on `EINTR`.
|
||||||
|
*
|
||||||
* See the C library manual for more details about fsync().
|
* See the C library manual for more details about fsync().
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, or -1 if an error occurred.
|
* Returns: 0 on success, or -1 if an error occurred.
|
||||||
@ -1676,8 +1679,14 @@ g_fsync (gint fd)
|
|||||||
{
|
{
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
return _commit (fd);
|
return _commit (fd);
|
||||||
|
#elif defined(HAVE_FSYNC)
|
||||||
|
int retval;
|
||||||
|
do
|
||||||
|
retval = fsync (fd);
|
||||||
|
while (G_UNLIKELY (retval < 0 && errno == EINTR));
|
||||||
|
return retval;
|
||||||
#else
|
#else
|
||||||
return fsync (fd);
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user