Hi folks,

in Solaris 10 apparently O_CLOEXEC is not defined.
(got a bug report in http://gnats.netbsd.org/54025)

Attached is a patch wrapping the code using it in #ifdef O_CLOEXEC.

thanks.
>From e9d262e43c6d4ada77f1b722f352fb55a4107ec0 Mon Sep 17 00:00:00 2001
From: Maya Rashish <co...@sdf.org>
Date: Thu, 28 Feb 2019 15:26:52 +0200
Subject: [PATCH 1/1] Handle O_CLOEXEC not being defined (Solaris 10)

---
 examples/loadables/fdflags.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/examples/loadables/fdflags.c b/examples/loadables/fdflags.c
index f3094666..30355c9f 100644
--- a/examples/loadables/fdflags.c
+++ b/examples/loadables/fdflags.c
@@ -113,8 +113,10 @@ getflags(int fd, int p)
       return -1;
     }
 
+#ifdef O_CLOEXEC
   if (c)
     f |= O_CLOEXEC;
+#endif
 
   return f & getallflags();
 }
@@ -198,6 +200,7 @@ setone(int fd, char *v, int verbose)
 
   parseflags(v, &pos, &neg);
 
+#ifdef O_CLOEXEC
   cloexec = -1;
   if ((pos & O_CLOEXEC) && (f & O_CLOEXEC) == 0)
     cloexec = FD_CLOEXEC;
@@ -209,6 +212,7 @@ setone(int fd, char *v, int verbose)
   pos &= ~O_CLOEXEC;
   neg &= ~O_CLOEXEC;
   f &= ~O_CLOEXEC;
+#endif
 
   n = f;
   n |= pos;
-- 
2.20.1

Reply via email to