ast_comparator/test/student_data/handout/shlab-handout/cases/reference_5_tsh.c
/* list_job - List all jobs running in background and foreground 
 *
 * If outfile is not NULL, then do I/O redirection;
 * else, call listjobs function
 */
List all jobs running in background and foreground
If outfile is not NULL, then do I/O redirection;
else, call listjobs function
List all jobs running in background and foreground If outfile is not NULL then do I / O redirection ; else call listjobs function
void 
list_job(struct cmdline_tokens* tok_ptr)
{
    if (tok_ptr->outfile != NULL) {
        int out_fd;  
        if ((out_fd = open(tok_ptr->outfile, O_WRONLY)) != -1) {      
            listjobs(job_list, out_fd);
            close(out_fd);
        }
        else {
            unix_error("Error in open");
        }
    }
    else {
        listjobs(job_list, STDOUT_FILENO);
    }
}
void list_job ( struct cmdline_tokens * tok_ptr ) { if ( tok_ptr -> outfile != NULL ) { int out_fd ; if ( ( out_fd = open ( tok_ptr -> outfile , O_WRONLY ) ) != -1 ) { listjobs ( job_list , out_fd ) ; close ( out_fd ) ; } else { unix_error ( " " ) ; } } else { listjobs ( job_list , STDOUT_FILENO ) ; } }
list_job - List all jobs running in background and foreground
 If outfile is not NULL, then do I/O redirection;
 else, call listjobs function
list_job - List all jobs running in background and foreground If outfile is not NULL then do I / O redirection ; else call listjobs function
/* outfile needs to be redirected */ /* List jobs using new file descripter out_fd */ /* List jobs using stdout */