summaryrefslogtreecommitdiff
path: root/user/fork.c
blob: d534fcf2a9ec3e61640b5af415c3e0d8d65f4118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <unistd.h>
#include <stdio.h>

int main(void)
{
	printf("im going to print some a's and b's. get ready\n");

	int pid = fork();
	if (pid < 0) {
		fprintf(stderr, "fork failed!\n");
		return 1;
	}

	for (int i = 0; i < 10; i++) {
		putchar(pid == 0 ? 'a' : 'b');
		putchar('\n');
	}

	return 0;
}