|
|
@ -35,17 +35,16 @@ int main() |
|
|
|
{ |
|
|
|
history[i] = (char *)calloc(CMDLINE_MAX_SIZE, sizeof(char)); |
|
|
|
} |
|
|
|
/* Install the signal handlers */ |
|
|
|
|
|
|
|
/* These are the ones you will need to implement */ |
|
|
|
/* Install the signal handlers */ |
|
|
|
Signal(SIGINT, sigint_handler); /* ctrl-c */ |
|
|
|
Signal(SIGTSTP, sigtstp_handler); /* ctrl-z */ |
|
|
|
Signal(SIGCHLD, sigchld_handler); /* Terminated or stopped child */ |
|
|
|
|
|
|
|
/* This one provides a clean way to kill the shell */ |
|
|
|
Signal(SIGQUIT, sigquit_handler); |
|
|
|
|
|
|
|
/* initiate job list */ |
|
|
|
initjobs(jobs); |
|
|
|
|
|
|
|
/* execute the shell's read, parse and execution loop */ |
|
|
|
do |
|
|
|
{ |
|
|
@ -524,6 +523,20 @@ struct job_t *getjobjid(struct job_t *jobs, int jid) |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
int maxjid(struct job_t *jobs) |
|
|
|
{ |
|
|
|
int i, max = 0; |
|
|
|
|
|
|
|
for (i = 0; i < JOBS_MAX_QUANTITY; i++) |
|
|
|
{ |
|
|
|
if (jobs[i].jid > max) |
|
|
|
{ |
|
|
|
max = jobs[i].jid; |
|
|
|
} |
|
|
|
} |
|
|
|
return max; |
|
|
|
} |
|
|
|
|
|
|
|
handler_t *Signal(int signum, handler_t *handler) |
|
|
|
{ |
|
|
|
struct sigaction action, old_action; |
|
|
|