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 PR/51859: Ngie Cooper: use closefrom/rest...
details: https://anonhg.NetBSD.org/src/rev/a44d4d2662d8
branches: trunk
changeset: 350574:a44d4d2662d8
user: christos <christos%NetBSD.org@localhost>
date: Fri Jan 13 21:19:45 2017 +0000
description:
PR/51859: Ngie Cooper: use closefrom/restore RLIMIT_NOFILE when done
diffstat:
tests/lib/libc/sys/t_pipe2.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diffs (57 lines):
diff -r aed1c3791f99 -r a44d4d2662d8 tests/lib/libc/sys/t_pipe2.c
--- a/tests/lib/libc/sys/t_pipe2.c Fri Jan 13 21:18:33 2017 +0000
+++ b/tests/lib/libc/sys/t_pipe2.c Fri Jan 13 21:19:45 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_pipe2.c,v 1.8 2012/05/16 13:54:28 jruoho Exp $ */
+/* $NetBSD: t_pipe2.c,v 1.9 2017/01/13 21:19:45 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_pipe2.c,v 1.8 2012/05/16 13:54:28 jruoho Exp $");
+__RCSID("$NetBSD: t_pipe2.c,v 1.9 2017/01/13 21:19:45 christos Exp $");
#include <atf-c.h>
#include <fcntl.h>
@@ -53,7 +53,8 @@
while ((i = open("/", O_RDONLY)) < 3)
ATF_REQUIRE(i != -1);
- ATF_REQUIRE(fcntl(3, F_CLOSEM) != -1);
+ ATF_REQUIRE_MSG(closefrom(3) != -1, "closefrom failed: %s",
+ strerror(errno));
ATF_REQUIRE(pipe2(fd, flags) == 0);
@@ -110,9 +111,10 @@
{
struct rlimit rl;
int err, filedes[2];
+ int old;
- err = fcntl(4, F_CLOSEM);
- ATF_REQUIRE(err == 0);
+ ATF_REQUIRE_MSG(closefrom(4) != -1, "closefrom failed: %s",
+ strerror(errno));
err = getrlimit(RLIMIT_NOFILE, &rl);
ATF_REQUIRE(err == 0);
@@ -121,12 +123,15 @@
* file descriptor limit in the middle of a pipe2() call - i.e.
* before the call only a single descriptor may be openend.
*/
+ old = rl.rlim_cur;
rl.rlim_cur = 4;
err = setrlimit(RLIMIT_NOFILE, &rl);
ATF_REQUIRE(err == 0);
err = pipe2(filedes, O_CLOEXEC);
ATF_REQUIRE(err == -1);
+ rl.rlim_cur = old;
+ err = setrlimit(RLIMIT_NOFILE, &rl);
}
ATF_TC(pipe2_nonblock);
Home |
Main Index |
Thread Index |
Old Index