Hello,
I don't know where is the problem in my code, since in the debbuger I cannot see what goes on with the child process. May someone help.
Code:
void addJob(int pid, int status){
jobs* temp = job;
if (temp == NULL){
temp = malloc(sizeof(jobs*));
job = temp;
}
else{
while (temp != NULL) temp = temp->next;
temp = malloc(sizeof(jobs*));
}
temp->pid = pid;
temp->status = status; /* foreground */
}
exe(){
....
if (pid == 0){
pid_t npid = getpid();
printf("If successful, the process ID will be %d.\n",npid); fflush(stdout); /* I know it reaches here */
addJob(npid, (bg)? 0:1);
if (execvp(*args, args) == -1){ perror("executing command\n"); exit(1);}
}
where job is a global variable.
May I know why the statement is not executed, or is so but not adding to the list? Is it an issue of shared memory amongst the processes? I've put jobs as a static variable in a header file and imported it but I still get no difference.