summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2014-08-04 09:52:09 +0200
committerVijay Bellur <vbellur@redhat.com>2014-10-30 01:39:51 -0700
commit3b022b19b77c3a159682b76998fa9ac9518e1c3c (patch)
tree59689075ffdbfce9c85e32823009e0d27b216470 /contrib
parentfb2e0a4afbe3263ebda3e1d2b72d921b2d7e2c50 (diff)
Use F_CLOSEM if available
Use F_CLOSEM to close all file descriptors if available. BUG: 764655 Change-Id: Ib3c682825b89c163ebb152848f2533b3cb62cdce Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org> Reviewed-on: http://review.gluster.org/8379 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/uuid/gen_uuid.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/contrib/uuid/gen_uuid.c b/contrib/uuid/gen_uuid.c
index 79923cd..e69995a 100644
--- a/contrib/uuid/gen_uuid.c
+++ b/contrib/uuid/gen_uuid.c
@@ -465,6 +465,12 @@ static ssize_t read_all(int fd, char *buf, size_t count)
#if defined(USE_UUIDD) && defined(HAVE_SYS_UN_H)
static void close_all_fds(void)
{
+#ifdef F_CLOSEM
+ (void)fcntl(0, F_CLOSEM);
+ (void)open("/dev/null", O_RDWR); /* stdin */
+ (void)open("/dev/null", O_RDWR); /* stdout */
+ (void)open("/dev/null", O_RDWR); /* stderr */
+#else /* F_CLOSEM */
int i, max;
#if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
@@ -485,6 +491,7 @@ static void close_all_fds(void)
if (i <= 2)
open("/dev/null", O_RDWR);
}
+#endif /* F_CLOSEM */
}
#endif