Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions zeromaps.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
void *thread(void *x) { open("x/blockme", 0); return 0; }

int main() {
pthread_t t;
pthread_create(&t, 0, thread, 0);
sleep(1);

puts("spawned thread");

FILE *mapsfile = fopen("/proc/self/maps", "r");

struct m { long start, end; };
Expand Down Expand Up @@ -72,5 +66,22 @@ void f() {
printf("BTW MY PID IS %d\n", getpid());

puts("start unmapping like crazy");

#ifdef PANIC_KERNEL
/* all forked processes share the same mapped memory */
while (fork() <= 0) { // maximize the effect
#endif

pthread_t t;
pthread_create(&t, 0, thread, 0);
sleep(1);

#ifndef PANIC_KERNEL
puts("spawned thread");
#endif

f();
#ifdef PANIC_KERNEL
}
#endif
}