Patch from Tom Hughes: set VG_(max_fd) based on the current file
descriptor limit rather than assuming 1024.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2127 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c
index dbf78eb..850e178 100644
--- a/coregrind/vg_mylibc.c
+++ b/coregrind/vg_mylibc.c
@@ -1203,13 +1203,13 @@
{
Int newfd;
- newfd = VG_(fcntl)(oldfd, VKI_F_DUPFD, VG_MAX_FD+1);
+ newfd = VG_(fcntl)(oldfd, VKI_F_DUPFD, VG_(max_fd)+1);
if (newfd != -1)
VG_(close)(oldfd);
VG_(fcntl)(newfd, VKI_F_SETFD, VKI_FD_CLOEXEC);
- vg_assert(newfd > VG_MAX_FD);
+ vg_assert(newfd > VG_(max_fd));
return newfd;
}
@@ -1429,6 +1429,17 @@
}
+/* Support for setrlimit. */
+Int VG_(setrlimit) (Int resource, struct vki_rlimit *rlim)
+{
+ Int res;
+ /* res = setrlimit( resource, rlim ); */
+ res = VG_(do_syscall)(__NR_setrlimit, (UInt)resource, (UInt)rlim);
+ if(VG_(is_kerror)(res)) res = -1;
+ return res;
+}
+
+
/* Support for getdents. */
Int VG_(getdents) (UInt fd, struct vki_dirent *dirp, UInt count)
{