ast_comparator/test/student_data/handout/shlab-handout/cases/36_tsh.c
/*
 * waitfg - Block until process pid is no longer the foreground process
 */
Block until process pid is no longer the foreground process
Block until process pid is no longer the foreground process
void waitfg(pid_t pid)
{
  int status;
  struct job_t *target = getjobpid(jobs, pid);
  if(target == NULL)
    return;
  if(waitpid(pid, &status, WUNTRACED) == -1)
    perror("waitpid");
  if(WIFSIGNALED(status))
    handle_sig(target, WTERMSIG(status));
  else if(WIFSTOPPED(status))
    handle_sig(target, WSTOPSIG(status));
  else{
    deletejob(jobs, pid);
  }
  return;
}
void waitfg ( pid_t pid ) { int status ; struct job_t * target = getjobpid ( jobs , pid ) ; if ( target == NULL ) return ; if ( waitpid ( pid , & status , WUNTRACED ) == -1 ) perror ( " " ) ; if ( WIFSIGNALED ( status ) ) handle_sig ( target , WTERMSIG ( status ) ) ; else if ( WIFSTOPPED ( status ) ) handle_sig ( target , WSTOPSIG ( status ) ) ; else { deletejob ( jobs , pid ) ; } return ; }
waitfg - Block until process pid is no longer the foreground process
waitfg - Block until process pid is no longer the foreground process
/* child received SIGINT */ /* child received SIGTSTP */ /* child terminated normally */