Shell job control
- by user1535672
For my school project I am implementing a shell and I need help with job control.
If we type a command, say cat &, then because of the & it should run in background, but it's not working. I have this code:
{
int pid;
int status;
pid = fork();
if (pid == 0) {
fprintf(stderr, "Child Job pid = %d\n", getpid());
execvp(arg1, arg2);
}
pid=getpid();
fprintf(stderr, "Child Job pid is = %d\n", getpid());
waitpid(pid, &status, 0);
}