Bläddra i källkod

adjust the format

master
10195501441 3 år sedan
förälder
incheckning
683e426f2c
3 ändrade filer med 20 tillägg och 4 borttagningar
  1. Binär
      yeeshell
  2. +17
    -4
      yeeshell.c
  3. +3
    -0
      yeeshell.h

Binär
yeeshell Visa fil


+ 17
- 4
yeeshell.c Visa fil

@ -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 Visa fil

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

||||||
x
 
000:0
Laddar…
Avbryt
Spara