#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

#define MAXLINE 256

#define SUCCESS "Password verified\n"
#define INVALID "Invalid password\n"
#define NO_USER "No such user\n"

int main(void) {
  char user_id[MAXLINE];
  char password[MAXLINE];

  /* The user will type in a user name on one line followed by a password 
     on the next.
     DO NOT add any prompts.  The only output of this program will be one 
	 of the messages defined above.
     Please read the comments in validate carefully
   */

  if(fgets(user_id, MAXLINE, stdin) == NULL) {
      perror("fgets");
      exit(1);
  }
  if(fgets(password, MAXLINE, stdin) == NULL) {
      perror("fgets");
      exit(1);
  }
  

  int fd[2];
  if(pipe(fd) == -1) {
      perror("pipe");
      exit(1);
  }
  int read_end = fd[0];
  int write_end = fd[1];
  pid_t pid = fork();

  //child process
  if (pid == 0){
      close(write_end);
      dup2(read_end, STDIN_FILENO);
      close(read_end);
      execl("./validate", "validate", NULL);
  }
  // parent process
  else if (pid > 0){
      close(read_end);
      write(write_end, user_id, strlen(user_id));
      write(write_end, password, strlen(password));
      close(write_end);
      int status;
      wait(&status);

      if (WIFEXITED(status)){
          int exit_status = WEXITSTATUS(status);
          if (exit_status == 0){
              printf("%s\n", SUCCESS);
          }
          else if (exit_status == 1){
              printf("%s\n", INVALID);
          }
          else if (exit_status == 2){
              printf("%s\n", NO_USER);
          }
      }
      else{
          perror("wait");
          exit(1);
      }

  }
  else{
      perror("fork");
      exit(1);
  }



  return 0;
}

the program run from excl in line 49 cannot read from stdin.