previous | start | next

Data Structures for Jobs

A job is essentially a process group consisting of a process created by the shell together with its descendant processes.

If a ctrl-z is typed while job is running in the foreground, a SIGTSTP signal should be sent to every process in that job (process group).

A job will be in one of these states:

A job is represented by a struct

struct job_t {              /* The job struct */
    pid_t pid;              /* job PID */
    int jid;                /* job ID [1, 2, ...] */
    int state;              /* UNDEF, BG, FG, or ST */
    char cmdline[MAXLINE];  /* command line */
};
     

The set of current jobs is stored in an array of these structs:

struct job_t jobs[MAXJOBS]; /* The job list */  
     


previous | start | next