Print this page
11530 badseg test creates cores

@@ -8,18 +8,20 @@
  * source.  A copy of the CDDL is also available via the Internet at
  * http://www.illumos.org/license/CDDL.
  */
 
 /*
- * Copyright 2018 Joyent, Inc.
+ * Copyright 2019 Joyent, Inc.
  */
 
 #include <stdlib.h>
 #include <ucontext.h>
 #include <sys/wait.h>
 #include <unistd.h>
 #include <sys/regset.h>
+#include <sys/resource.h>
+#include <err.h>
 
 /*
  * Load a bunch of bad selectors into the seg regs: this will typically cause
  * the child process to core dump, but it shouldn't panic the kernel...
  *

@@ -115,13 +117,13 @@
         pid_t pid;
 
         switch ((pid = fork())) {
         case 0:
                 func();
-                exit(0);
+                exit(EXIT_SUCCESS);
         case -1:
-                exit(1);
+                exit(EXIT_FAILURE);
         default:
                 (void) waitpid(pid, NULL, 0);
                 return;
         }
 

@@ -128,10 +130,16 @@
 }
 
 int
 main(int argc, char *argv[])
 {
+        struct rlimit rl = { 0, };
+
+        if (setrlimit(RLIMIT_CORE, &rl) != 0) {
+                err(EXIT_FAILURE, "failed to disable cores");
+        }
+
         for (selector = 0; selector < 8194; selector++) {
                 inchild(resetcs);
                 inchild(resetds);
                 inchild(resetes);
                 inchild(resetfs);

@@ -142,7 +150,7 @@
                 inchild(badfs);
                 inchild(badgs);
                 inchild(badss);
         }
 
-        exit(0);
+        exit(EXIT_SUCCESS);
 }