diff --git a/yeeshell b/yeeshell index ba5008e..84f66a6 100755 Binary files a/yeeshell and b/yeeshell differ diff --git a/yeeshell.c b/yeeshell.c index ae5ff24..bd3ab68 100644 --- a/yeeshell.c +++ b/yeeshell.c @@ -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; diff --git a/yeeshell.h b/yeeshell.h index b1c2152..7fa40cb 100644 --- a/yeeshell.h +++ b/yeeshell.h @@ -72,6 +72,9 @@ struct job_t *getjobpid(struct job_t *jobs, pid_t pid); /* getjobjid - Find a job (by JID) on the job list */ struct job_t *getjobjid(struct job_t *jobs, int jid); +/* maxjid - Returns largest allocated job ID */ +int maxjid(struct job_t *jobs); + /* Signal - wrapper for the sigaction function */ typedef void handler_t(int); handler_t *Signal(int signum, handler_t *handler);