summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Henk <csaba@redhat.com>2012-04-03 01:57:23 +0200
committerVijay Bellur <vijay@gluster.com>2012-04-02 23:11:20 -0700
commite5b5bb4de46a2a37c8ff392c456c306026517269 (patch)
tree2619c15f0c31fbe41ce5cd83eea63f91bcd6a7ca
parent1043dedfb54c80bdbb6e050920ced204515b226e (diff)
libglusterfs/run: POSIX compatible closing of child fds on non-Linux
It just occurred to me that I realized there are POSIX features that let this be done cleanly. However, For Linux we keep the proc based approach to get more graceful strace logs. Change-Id: I6b473271b2adfd85cef6612eb65d88e5d00f5943 BUG: 764294 Signed-off-by: Csaba Henk <csaba@redhat.com> Reviewed-on: http://review.gluster.com/3068 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--libglusterfs/src/run.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libglusterfs/src/run.c b/libglusterfs/src/run.c
index 0dbf33b9d..f6f193143 100644
--- a/libglusterfs/src/run.c
+++ b/libglusterfs/src/run.c
@@ -31,6 +31,7 @@
#include <dirent.h>
#include <assert.h>
#include <sys/wait.h>
+#include <sys/resource.h>
#ifdef RUN_STANDALONE
#define GF_CALLOC(n, s, t) calloc(n, s)
@@ -293,7 +294,11 @@ runner_start (runner_t *runner)
} else
ret = -1;
#else
- for (i = 3; i < 65536; i++) {
+ struct rlimit rl;
+ ret = getrlimit (RLIMIT_NOFILE, &rl);
+ GF_ASSERT (ret == 0);
+
+ for (i = 3; i < rl.rlim_cur; i++) {
if (i != xpi[1])
close (i);
}