aboutsummaryrefslogtreecommitdiff
path: root/tests/fork-exhaustion/init.c
blob: 77586130d6fcd00f2a9296d09035f7982f2aa846 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <common/test.h>

START(pid, tid, d0, d1, d2, d3)
{
	UNUSED(pid);
	UNUSED(tid);
	UNUSED(d0);
	UNUSED(d1);
	UNUSED(d2);
	UNUSED(d3);

	check(pid == 0, "illegal pid for init\n");
	id_t our_id = 0;

	int counter = 0;
	while (1) {
		printf("forking %d\n", counter++);
		id_t new_id = sys_fork(&our_id);
		if (new_id < 0)
			break;
	}

	/* if kernel didn't crash, we consider it a success */
	ok();
}