[glib: 1/2] gio-unix: Use EPOLL_CLOEXEC by default




commit 426fab1eca12ce12bd035cb76f43ff73a94bd8bd
Author: Colin Walters <walters verbum org>
Date:   Fri Aug 26 04:05:40 2022 -0400

    gio-unix: Use EPOLL_CLOEXEC by default
    
    First, there's no reason not to use the new `epoll_create1` system call,
    which quickly obsoleted `epoll_create` which has an obsolete and
    unused size argument.
    
    But more specifically, it offers `EPOLL_CLOEXEC` which we want
    to use for general hygeine - there's no reason to potentially
    leak this file descriptor to forked processes.
    
    (GLib itself carefully closes file descriptors when forking child
     processes, but it may be linked with other software that doesn't;
     notably in my case for example the Rust standard library does not
     do this and hence relies more on the application code using
     `O_CLOEXEC` and variants)
    
    This is just a drive-by fix; I saw the system call when I was using
    `strace` to debug something else in rpm-ostree.

 gio/giounix-private.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gio/giounix-private.c b/gio/giounix-private.c
index b7d0b6b319..0e66af888a 100644
--- a/gio/giounix-private.c
+++ b/gio/giounix-private.c
@@ -82,9 +82,9 @@ _g_fd_is_pollable (int fd)
   struct epoll_event ev = { 0, };
   gboolean add_succeeded;
 
-  efd = epoll_create (1);
+  efd = epoll_create1 (EPOLL_CLOEXEC);
   if (efd == -1)
-    g_error ("epoll_create () failed: %s", g_strerror (errno));
+    g_error ("epoll_create1 () failed: %s", g_strerror (errno));
 
   ev.events = EPOLLIN;
 


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