ast_comparator/test/student_data/handout/shlab-handout/cases/reference_24_tsh.c
int addjob(struct job_t *jobs, pid_t pid, int state, char *cmdline, pid_t pid2) 
{
    int i;
    
    if (pid < 1)
	return 0;

    for (i = 0; i < MAXJOBS; i++) {
	if (jobs[i].pid == 0) {
	    jobs[i].pid = pid;
	    jobs[i].pid2 = pid2;
	    jobs[i].state = state;
	    jobs[i].jid = nextjid++;
	    if (nextjid > MAXJOBS)
		nextjid = 1;
	    strcpy(jobs[i].cmdline, cmdline);
	    if(state == BG)
	    {
	      //Print bg info
	      printf("[%d] (%d) %s", jobs[i].jid, jobs[i].pid,jobs[i].cmdline);
	    }
	    
	    
  	    if(verbose){
	        printf("Added job [%d] %d %s pid2:%d\n", jobs[i].jid, jobs[i].pid, jobs[i].cmdline,jobs[i].pid2);
            }
            return 1;
	}
    }
    printf("Tried to create too many jobs\n");
    return 0;
}
/* addjob - Add a job to the job list */
Add a job to the job list
Add a job to the job list
int addjob(struct job_t *jobs, pid_t pid, int state, char *cmdline, pid_t pid2) 
{
    int i;
    if (pid < 1)
	return 0;
    for (i = 0; i < MAXJOBS; i++) {
	if (jobs[i].pid == 0) {
	    jobs[i].pid = pid;
	    jobs[i].pid2 = pid2;
	    jobs[i].state = state;
	    jobs[i].jid = nextjid++;
	    if (nextjid > MAXJOBS)
		nextjid = 1;
	    strcpy(jobs[i].cmdline, cmdline);
	    if(state == BG)
	    {
	      printf("[%d] (%d) %s", jobs[i].jid, jobs[i].pid,jobs[i].cmdline);
	    }
  	    if(verbose){
	        printf("Added job [%d] %d %s pid2:%d\n", jobs[i].jid, jobs[i].pid, jobs[i].cmdline,jobs[i].pid2);
            }
            return 1;
	}
    }
    printf("Tried to create too many jobs\n");
    return 0;
}
int addjob ( struct job_t * jobs , pid_t pid , int state , char * cmdline , pid_t pid2 ) { int i ; if ( pid < 1 ) return 0 ; for ( i = 0 ; i < MAXJOBS ; i ++ ) { if ( jobs [ i ] . pid == 0 ) { jobs [ i ] . pid = pid ; jobs [ i ] . pid2 = pid2 ; jobs [ i ] . state = state ; jobs [ i ] . jid = nextjid ++ ; if ( nextjid > MAXJOBS ) nextjid = 1 ; strcpy ( jobs [ i ] . cmdline , cmdline ) ; if ( state == BG ) { printf ( " " , jobs [ i ] . jid , jobs [ i ] . pid , jobs [ i ] . cmdline ) ; } if ( verbose ) { printf ( " \n " , jobs [ i ] . jid , jobs [ i ] . pid , jobs [ i ] . cmdline , jobs [ i ] . pid2 ) ; } return 1 ; } } printf ( " \n " ) ; return 0 ; }
addjob - Add a job to the job list
addjob - Add a job to the job list
//Print bg info