Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Do not try to open files up to the RLIMIT...



details:   https://anonhg.NetBSD.org/src/rev/bfb25562db5d
branches:  trunk
changeset: 770023:bfb25562db5d
user:      njoly <njoly%NetBSD.org@localhost>
date:      Fri Sep 30 21:08:19 2011 +0000

description:
Do not try to open files up to the RLIMIT_NOFILE limit, which fails
when process limit is identical to the whole system limit. Just do it
for a small fixed value, and adjust the limit accordingly instead.

diffstat:

 tests/lib/libc/sys/t_dup.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (42 lines):

diff -r 8747d7409c5e -r bfb25562db5d tests/lib/libc/sys/t_dup.c
--- a/tests/lib/libc/sys/t_dup.c        Fri Sep 30 19:12:35 2011 +0000
+++ b/tests/lib/libc/sys/t_dup.c        Fri Sep 30 21:08:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dup.c,v 1.5 2011/07/18 04:29:37 jruoho Exp $ */
+/* $NetBSD: t_dup.c,v 1.6 2011/09/30 21:08:19 njoly Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,13 +29,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_dup.c,v 1.5 2011/07/18 04:29:37 jruoho Exp $");
+__RCSID("$NetBSD: t_dup.c,v 1.6 2011/09/30 21:08:19 njoly Exp $");
 
 #include <sys/resource.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 
 #include <atf-c.h>
+#include <err.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
@@ -300,13 +301,11 @@
                (void)closefrom(0);
                (void)memset(&res, 0, sizeof(struct rlimit));
 
-               if (getrlimit(RLIMIT_NOFILE, &res) != 0)
+               n = 10;
+               res.rlim_cur = res.rlim_max = n;
+               if (setrlimit(RLIMIT_NOFILE, &res) != 0)
                        _exit(EX_OSERR);
 
-               if (res.rlim_cur == 0 || res.rlim_max == 0)
-                       _exit(EX_OSERR);
-
-               n = res.rlim_cur;
                buf = calloc(n, sizeof(int));
 
                if (buf == NULL)



Home | Main Index | Thread Index | Old Index