2 * Test a fork/munmap vm_object shadow chain race
4 * Written by "Samuel J. Greear" <sjg@evilcode.net>
12 #include <sys/types.h>
14 #include <sys/param.h>
17 #define MAPPING_PAGES 4096
20 main(int argc, char *argv[])
28 for (i = 1; i < MAPPING_PAGES; ++i) {
30 mapping = mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED,
32 if (mapping == MAP_FAILED)
33 errx(EX_OSERR, "mmap() failed");
35 memset(mapping, 'x', 10);
41 memcpy(&tmp, mapping, 12);
43 } else if (pid != -1) {
44 if (munmap(mapping, PAGE_SIZE * i) != 0) {
45 printf("munmap failed\n");
48 waitpid(pid, &status, 0);
50 printf("child sig10 at %d pages\n", i);
54 printf("fork failed\n");