#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>

int main(void) {
int i, ctr, pid, fd;
const char str[] = "Greetings from outer space\n";

for (i = 0, ctr = 0; i < 1000; i++) {
	if ((pid = fork()) == 0) {
		fd = open("et.txt", O_WRONLY | O_CREAT, 0644);
		lseek(fd, 0, SEEK_END);
		write(fd, str, sizeof(str));
		close(fd);
		exit(0);
	}
	else if (pid > 0)
		ctr++;
}
printf("Successfully created %d processes\n", ctr);
return 0;
}
