Browse Source

adjust the format

master
10195501441 3 years ago
parent
commit
683e426f2c
3 changed files with 20 additions and 4 deletions
  1. BIN
      yeeshell
  2. +17
    -4
      yeeshell.c
  3. +3
    -0
      yeeshell.h

BIN
yeeshell View File


+ 17
- 4
yeeshell.c View File

@ -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;

+ 3
- 0
yeeshell.h View File

@ -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);

Loading…
Cancel
Save