ast_comparator/test/student_data/handout/shlab-handout/cases/reference_32_tsh.c
/* 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) {
int i;
if (pid < 1)
return 0;
for (i = 0; i < MAXJOBS; i++) {
if (jobs->pid == 0) {
jobs->pid = pid;
jobs->state = state;
jobs->jid = nextjid++;
if (nextjid > MAXJOBS)
nextjid = 1;
strcpy(jobs->cmdline, cmdline);
if (verbose) {
printf("Added job [%d] %d %s\n", jobs->jid, jobs->pid,
jobs->cmdline);
}
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 ) { int i ; if ( pid < 1 ) return 0 ; for ( i = 0 ; i < MAXJOBS ; i ++ ) { if ( jobs -> pid == 0 ) { jobs -> pid = pid ; jobs -> state = state ; jobs -> jid = nextjid ++ ; if ( nextjid > MAXJOBS ) nextjid = 1 ; strcpy ( jobs -> cmdline , cmdline ) ; if ( verbose ) { printf ( " \n " , jobs -> jid , jobs -> pid , jobs -> cmdline ) ; } return 1 ; } } printf ( " \n " ) ; return 0 ; }
addjob - Add a job to the job list
addjob - Add a job to the job list