[glib] gstdio: Harden g_open() against EINTR



commit ce976bcac7294e72b3e94dda17fe5dfb157770d4
Author: Colin Walters <walters verbum org>
Date:   Mon Aug 27 14:37:21 2012 -0400

    gstdio: Harden g_open() against EINTR
    
    Noticed by code inspection, when auditing some of my code for EINTR
    handling.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=682819

 glib/gstdio.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/glib/gstdio.c b/glib/gstdio.c
index 6d763e1..71431f1 100644
--- a/glib/gstdio.c
+++ b/glib/gstdio.c
@@ -40,6 +40,7 @@
 #include <sys/utime.h>
 #else
 #include <utime.h>
+#include <errno.h>
 #endif
 
 #include "gstdio.h"
@@ -209,7 +210,11 @@ g_open (const gchar *filename,
   errno = save_errno;
   return retval;
 #else
-  return open (filename, flags, mode);
+  int fd;
+  do
+    fd = open (filename, flags, mode);
+  while (G_UNLIKELY (fd == -1 && errno == EINTR));
+  return fd;
 #endif
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]