This code gives me could not read from stdin error. Fix that
#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);  
  }  

  // TODO 
  int ret;
  int fd[2];
  
  ret = fork();
  if (ret < 0) {
  	perror("pipe");
  }
  if (pipe(fd) == -1) {
  	perror("pipe");
  	exit(1);
  }
  

  if (ret == 0) { // child process
  	close(fd[1]);
  	dup2(fd[0], STDIN_FILENO);
  	execl("./validate", "validate", NULL);
  	
  	close(fd[0]);
  	
  } else { // parent process
	close(fd[0]);
	dup2(fd[1], STDOUT_FILENO);
	
  	write(fd[1], user_id, strlen(user_id));
  	write(fd[1], password, strlen(password));
  	close(fd[1]);
  	
  	int status;
 	pid_t child_pid = wait(&status);

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