void parse_cmd(t_shell *sh, t_token *token) { t_job *job; t_process *process; job = NULL; process = NULL; while (token) { if (token->token_value == PIPE) { token_pipe(sh, &process, token); token = token->next; } else if (token->token_value == AND || token->token_value == OR || token->token_value == SEPARATOR) { token_linker(sh, &job, &process, token); token = token->next; } else { if ((token = hub_redir(sh, token)) == NULL) return ; } } exec_job(sh, job); }
void exec_job_list(job *job_list) { job *jb; for (jb = job_list; jb != NULL; jb = jb->next) { if (exec_job(jb->process_list, jb->mode) < 0) { abort(); } } }
int main(int argc, char *argv[]){ if(argc!=2){ printf("usage: prog joblibst\n"); printf("Run jobs with definite num. of seconds since run useless\n"); return EARG; } FILE *f; openf(f,argv[1],"r"); int sec; char * comm = NULL; size_t len = 0; while(fscanf(f,"%d ",&sec)==1){ getline(&comm, &len, f); add_job(comm,sec); } fclose(f); qsort(jobs,cnt,sizeof(joblist),cmp); print_job(); exec_job(); return SUCC; }