ret.cmd = job_cmd;
- for(int j = 0;
- j < jlen;
+ for(int j = 1;
+ j <= jlen;
j++){
- ret.args[j] = real_args[j];
+ ret.args[j] = real_args[j - 1];
}
- ret.args[jlen] = NULL;
+ ret.args[jlen + 1] = NULL;
+ ret.args[0] = ret.cmd;
return ret;
}
char *manifest = lookup_user_folder();
tomd_p("Loading jobs from '%s'", manifest);
- /* get into the manifest.scm file */
void *res =
scm_with_guile(load_manifest,
(void *) manifest);
}
tomd_p("JOB <%d>:", i);
tomd_p(" cmd:'%s'", jobs[i].cmd);
- int j = 0;
+ int j = 1;
while(1){
if(i >= 10 ||
jobs[i].args[j] == NULL){
i++;
}
}
+
+void run_job(int index)
+{
+ struct job *job = &jobs[index];
+
+ pid_t pid = fork();
+ if(pid == 0){ /* child */
+ int i = 0;
+ while(1){
+ tomd_p("hallo");
+ if(job->args[i] == NULL){
+ tomd_p("arg [%d] is NULL", i);
+ break;
+ }else{
+ tomd_p("arg [%d] is '%s'", i, job->args[i]);
+ }
+ i++;
+ }
+ execvp(job->cmd, job->args);
+ tomd_p("execvp for '%s' failed", job->cmd);
+ perror("");
+ exit(EXIT_FAILURE);
+ }else{ /* parent */
+ tomd_p("forked [%d] to run '%s'", pid, job->cmd);
+ }
+}
+
+void run_jobs(void)
+{
+ int i;
+ for(i = 0;
+ i < MAX_JOBS;
+ i++){
+ if(jobs[i].cmd == NULL){
+ tomd_p("out of jobs");
+ return;
+ }else{
+ tomd_p("running job [%d] '%s'", i, jobs[i].cmd);
+ run_job(i);
+ }
+ }
+}