ast_comparator/test/student_data/handout/shlab-handout/cases/45_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)
{
    sigset_t mask;
    if (sigemptyset(&mask) < 0) {
        unix_error("sigemptyset error");
    }
    while (pid == fgpid(jobs)) {
        sigsuspend(&mask);
    }
    return;
}
void waitfg ( pid_t pid ) { sigset_t mask ; if ( sigemptyset ( & mask ) < 0 ) { unix_error ( " " ) ; } while ( pid == fgpid ( jobs ) ) { sigsuspend ( & mask ) ; } return ; }
waitfg - Block until process pid is no longer the foreground process
waitfg - Block until process pid is no longer the foreground process
// avoid wasting cpu cycles by busy waiting // loops are runned only when any signal arrives