/* do_fg - Execute the builtin fg command */ void do_fg(char **argv) { struct job_t * job; pid_t pid; if (verbose) printf("do_fg: entering\n"); job = treat_argv(argv); job->jb_state = FG; pid = jobs_fgpid(); assert(kill(-pid, SIGCONT) != -1); if (verbose) printf("do_fg: sigcont %d \n", pid); waitfg(pid); if (verbose) printf("do_fg: exiting\n"); return; }
/* do_bg - Execute the builtin bg command */ void do_bg(char **argv) { struct job_t *job; int k; if (verbose) { printf("Entering BG\n"); } job = treat_argv(argv); if (job == NULL) { if (verbose) { printf("Non existing job : exiting waitfg\n"); } return; } job->jb_state = BG; k = kill(job->jb_pid,SIGCONT); if (k <0) { unix_error("kill error"); } if (verbose) { printf("Exiting BG\n"); } return; }
/* do_kill - Execute the builtin kill command */ void do_kill(char **argv) { struct job_t *job; int k; if (verbose) { printf("Entering kill\n"); } job = treat_argv(argv); if (job == NULL) { if (verbose) { printf("Non existing job : exiting kill\n"); } return; } k= kill(job->jb_pid,SIGKILL); if (k <0) { unix_error("kill error"); } if (verbose) { printf("Exiting kill\n"); } return; }
/* do_stop - Execute the builtin stop command */ void do_stop(char **argv) { struct job_t *job; int k; if (verbose) { printf("Entering stop\n"); } job = treat_argv(argv); if (job == NULL) { if(verbose) { printf("Non existing job : exiting stop\n"); return; } } job->jb_state = ST; k = kill(job->jb_pid,SIGSTOP); if (k <0) { unix_error("kill error"); } if (verbose) { printf("Exiting stop \n"); } return; }
/* do_kill - Execute the builtin kill command */ void do_kill(char **argv) { struct job_t * job; pid_t pid; if (verbose) printf("do_kill: entering\n"); job = treat_argv(argv); pid = job->jb_pid; assert(kill(-pid, SIGKILL) != -1); if (verbose) printf("do_kill: sigkill %d \n", pid); assert(jobs_deletejob(pid) != -1); if (verbose) printf("do_stop: exiting\n"); return; }
/* do_stop - Execute the builtin stop command */ void do_stop(char **argv) { struct job_t * job; pid_t pid; if (verbose) printf("do_stop: entering\n"); job = treat_argv(argv); job->jb_state = ST; pid = job->jb_pid; assert(kill(-pid, SIGSTOP) != -1); if (verbose) printf("do_stop: sigstop %d \n", pid); if (verbose) printf("do_stop: exiting\n"); return; }