Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/libc/gen PR/51807: Ngie Cooper: disable core file ...



details:   https://anonhg.NetBSD.org/src/rev/c0bebfed0748
branches:  trunk
changeset: 820474:c0bebfed0748
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Jan 10 15:17:57 2017 +0000

description:
PR/51807: Ngie Cooper: disable core file generation in :assert_false,
:assert_true

diffstat:

 tests/lib/libc/gen/t_assert.c |  20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diffs (56 lines):

diff -r 2eb3d1fcffe4 -r c0bebfed0748 tests/lib/libc/gen/t_assert.c
--- a/tests/lib/libc/gen/t_assert.c     Tue Jan 10 15:16:57 2017 +0000
+++ b/tests/lib/libc/gen/t_assert.c     Tue Jan 10 15:17:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $ */
+/* $NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,8 +29,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $");
+__RCSID("$NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $");
 
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/time.h>
 #include <sys/wait.h>
 
 #include <assert.h>
@@ -40,6 +43,17 @@
 #include <string.h>
 #include <unistd.h>
 
+static void
+disable_corefile(void)
+{
+       struct rlimit limits;
+
+       limits.rlim_cur = 0;
+       limits.rlim_max = 0;
+
+       ATF_REQUIRE(setrlimit(RLIMIT_CORE, &limits) == 0);
+}
+
 static void            handler(int);
 
 static void
@@ -65,6 +79,7 @@
 
        if (pid == 0) {
 
+               disable_corefile();
                (void)closefrom(0);
                (void)memset(&sa, 0, sizeof(struct sigaction));
 
@@ -102,6 +117,7 @@
 
        if (pid == 0) {
 
+               disable_corefile();
                (void)closefrom(0);
                (void)memset(&sa, 0, sizeof(struct sigaction));
 



Home | Main Index | Thread Index | Old Index