int main(int argc, char **argv) {
    if (argc != 2) {
        fprintf(stderr, "Usage: forkloop <iterations>\n");
        exit(1);
    }

    int iterations = strtol(argv[1], NULL, 10);

    int child_count = 0;

    for (int i = 0; i < iterations; i++) {
        if (child_count == i) {
            int n = fork();
            if (n < 0) {
                perror("fork");
                exit(1);
            }
            else if (n == 0) {
                child_count++;
            }
        }

        printf("ppid = %d, pid = %d, i = %d\n", getppid(), getpid(), i);
    }

    return 0;
}
each process creates exactly one new process