computer-system/CMU15-213/labs/LAB5_tshlab/tsh.c
int builtin_cmd(char **argv) {
    if(strcmp(argv[0], "quit") == 0) {
        /* Terminates the shell */
        exit(0);
    }
    else if(strcmp(argv[0], "fg") == 0 || strcmp(argv[0], "bg") == 0) {
        /* Do bg-fg switch */
        do_bgfg(argv);
        return 1;
    }
    else if(strcmp(argv[0], "jobs") == 0) {
        /* Need to block all signals to access global data structure */
        sigset_t mask_all, prev_all;
        Sigfillset(&mask_all);
        Sigprocmask(SIG_BLOCK, &mask_all, &prev_all);
        listjobs(jobs);
        Sigprocmask(SIG_SETMASK, &prev_all, NULL);
        return 1;
    }
    return 0;     /* not a builtin command */
}
/* 
 * builtin_cmd - If the user has typed a built-in command then execute
 *    it immediately.  
 */
If the user has typed a built-in command then execute
it immediately.
If the user has typed a built - in command then execute it immediately .
int builtin_cmd(char **argv) {
    if(strcmp(argv[0], "quit") == 0) {
        exit(0);
    }
    else if(strcmp(argv[0], "fg") == 0 || strcmp(argv[0], "bg") == 0) {
        do_bgfg(argv);
        return 1;
    }
    else if(strcmp(argv[0], "jobs") == 0) {
        sigset_t mask_all, prev_all;
        Sigfillset(&mask_all);
        Sigprocmask(SIG_BLOCK, &mask_all, &prev_all);
        listjobs(jobs);
        Sigprocmask(SIG_SETMASK, &prev_all, NULL);
        return 1;
    }
    return 0;     
}
int builtin_cmd ( char * * argv ) { if ( strcmp ( argv [ 0 ] , " " ) == 0 ) { exit ( 0 ) ; } else if ( strcmp ( argv [ 0 ] , " " ) == 0 || strcmp ( argv [ 0 ] , " " ) == 0 ) { do_bgfg ( argv ) ; return 1 ; } else if ( strcmp ( argv [ 0 ] , " " ) == 0 ) { sigset_t mask_all , prev_all ; Sigfillset ( & mask_all ) ; Sigprocmask ( SIG_BLOCK , & mask_all , & prev_all ) ; listjobs ( jobs ) ; Sigprocmask ( SIG_SETMASK , & prev_all , NULL ) ; return 1 ; } return 0 ; }
builtin_cmd - If the user has typed a built-in command then execute
    it immediately.
builtin_cmd - If the user has typed a built - in command then execute it immediately .
/* Terminates the shell */ /* Do bg-fg switch */ /* Need to block all signals to access global data structure */ /* not a builtin command */