[glib: 1/3] gspawn: safe_closefrom for Solaris 11.3/11.4




commit 790571a2cd5e1e7187500a356e587716bf1fd810
Author: Casper Dik <casper dik oracle com>
Date:   Sun Aug 1 12:43:19 2021 -0700

    gspawn: safe_closefrom for Solaris 11.3/11.4
    
    When F_CLOSEFROM is defined, we know that closefrom() is signal safe.

 glib/gspawn.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/glib/gspawn.c b/glib/gspawn.c
index 3073a10a4..c75619c08 100644
--- a/glib/gspawn.c
+++ b/glib/gspawn.c
@@ -1487,7 +1487,8 @@ safe_fdwalk (int (*cb)(void *data, int fd), void *data)
 static void
 safe_closefrom (int lowfd)
 {
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if defined(__FreeBSD__) || defined(__OpenBSD__) || \
+  (defined(__sun__) && defined(F_CLOSEFROM))
   /* Use closefrom function provided by the system if it is known to be
    * async-signal safe.
    *
@@ -1496,6 +1497,9 @@ safe_closefrom (int lowfd)
    *
    * OpenBSD: closefrom is not included in the list, but a direct system call
    * should be safe to use.
+   *
+   * In Solaris as of 11.3 SRU 31, closefrom() is also a direct system call.
+   * On such systems, F_CLOSEFROM is defined.
    */
   (void) closefrom (lowfd);
 #elif defined(__DragonFly__)


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