Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/eglib
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2014-11-22 04:31:30 +0300
committerZoltan Varga <vargaz@gmail.com>2014-11-22 04:31:36 +0300
commitcd9f3b5859bce24cc00f3620544bde581054a8dd (patch)
treee61541b61e9df0a1e583d319646ff1911f4dce21 /eglib
parentcb5c0f86f3a477dda50e8c9174da036b85e41675 (diff)
[runtime] Remove a getdtablesize () reference from eglib too.
Diffstat (limited to 'eglib')
-rw-r--r--eglib/configure.ac3
-rw-r--r--eglib/src/gspawn.c23
2 files changed, 24 insertions, 2 deletions
diff --git a/eglib/configure.ac b/eglib/configure.ac
index 1ff6c42ff28..5281419c00b 100644
--- a/eglib/configure.ac
+++ b/eglib/configure.ac
@@ -135,6 +135,7 @@ AC_CHECK_SIZEOF(void *)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
AC_CHECK_FUNCS(strlcpy stpcpy strtok_r rewinddir vasprintf)
+AC_CHECK_FUNCS(getrlimit)
#
# Mono currently supports 10.6, but strndup is not available prior to 10.7; avoiding
@@ -179,7 +180,7 @@ if test "x$have_iso_varargs" = "xyes"; then
fi
AC_SUBST(G_HAVE_ISO_VARARGS)
-AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h)
+AC_CHECK_HEADERS(getopt.h sys/select.h sys/time.h sys/wait.h pwd.h langinfo.h iconv.h localcharset.h sys/types.h sys/resource.h)
AC_CHECK_HEADER(alloca.h, [HAVE_ALLOCA_H=1], [HAVE_ALLOCA_H=0])
AC_SUBST(HAVE_ALLOCA_H)
diff --git a/eglib/src/gspawn.c b/eglib/src/gspawn.c
index 836e6f2aa9c..af629c1947e 100644
--- a/eglib/src/gspawn.c
+++ b/eglib/src/gspawn.c
@@ -53,6 +53,10 @@
#include <sys/wait.h>
#endif
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif
+
#ifdef G_OS_WIN32
#include <io.h>
#include <winsock2.h>
@@ -213,6 +217,23 @@ write_all (int fd, const void *vbuf, size_t n)
return nwritten;
}
+#ifndef G_OS_WIN32
+static int
+g_getdtablesize (void)
+{
+#ifdef HAVE_GETRLIMIT
+ struct rlimit limit;
+ int res;
+
+ res = getrlimit (RLIMIT_NOFILE, &limit);
+ g_assert (res == 0);
+ return limit.rlim_cur;
+#else
+ return getdtablesize ();
+#endif
+}
+#endif
+
gboolean
g_spawn_command_line_sync (const gchar *command_line,
gchar **standard_output,
@@ -256,7 +277,7 @@ g_spawn_command_line_sync (const gchar *command_line,
close (stderr_pipe [0]);
dup2 (stderr_pipe [1], STDERR_FILENO);
}
- for (i = getdtablesize () - 1; i >= 3; i--)
+ for (i = g_getdtablesize () - 1; i >= 3; i--)
close (i);
/* G_SPAWN_SEARCH_PATH is always enabled for g_spawn_command_line_sync */