my code looks like this.
Validate is a program that will validate the username and password.
If the password is correct for this user, it exits with 0.
If the password is incorrect, it exits with 2.
My program keeps exiting with 2 even with a correct password. I'm wondering if my pipes are incorrect
int fd[2];
if (pipe(fd) == -1) {
    perror("pipe");
}

int r = fork();

if (r > 0) {  // Parent
    close(fd[0]);
    // // Connect stdout to pipe
    // dup2(fd[1], fileno(stdout));
    // close(fd[1]);

    // Feed information into the pipe
    if (write(fd[1], user_id, MAXLINE) == -1) {
        perror("write to pipe");
    }
    if (write(fd[1], password, MAXLINE) == -1) {
        perror("write to pipe");
    }

    close(fd[1]);

    int status;
    if (wait(&status) != -1) {
        if (WIFEXITED(status)) {
            printf("[%d] Child exited with %d\n", getpid(), WEXITSTATUS(status));
        } else {
            printf("[%d] Child exited abnormally\n", getpid());
        }
    }
} else if (r == 0) {  // Child
    // Connect stdin to pipe
    dup2(fd[0], fileno(stdin));
    close(fd[0]);
    close(fd[1]);

    // Call exec for validate
    execl("./validate", "validate", NULL);
}