the code is meant to execute rules from a make file in parallel by having the parent create a child for each dependency. When compiled, the perror on line 29 runs. Why, and how do I fix this?
void parallel_eval(Rule *rule) {
    Dependency *dep_cur = rule->dependencies;
    int parentPID = getpid();
    while (dep_cur != NULL) {
        // create a child proccess for each dependency
        if (parentPID == getpid()) {
            // parent
            int n = fork();
            if (n < 0) {
                perror("Error: forking\n");
                exit(1);
            }
            if (n == 0) {
                // child
                parallel_eval(dep_cur->rule);
            }
        }
        dep_cur = dep_cur->next_dep;
    }
    if (parentPID == getpid()) {
        int status;
        wait(&status);
        if (status < 0) {
            perror("Error: wait \n");
            exit(1);
        }
        if (WIFEXITED(status)) {  // checks id process exits normally
            if (WEXITSTATUS(status) != 0) {
                perror("Error: child exit incorrectly");
                exit(1);
            } else if (WEXITSTATUS(status) == 1) {
                Action *act_cur = rule->actions;
                while (act_cur != NULL) {
                    execute(act_cur);
                    act_cur = act_cur->next_act;
                }
            }
        }
    } else {
        exit(compare_time(rule));  // check on this line ???
    }
}