Lines Matching full:job

72  * A job structure contains information about a job.  A job is either a
90 struct job { struct
94 pid_t pgrp; /* process group of this job */ argument
95 char state; /* true if job is finished */ argument
102 char jobctl; /* job running under job control */ argument
103 struct job *next; /* job used after this one */ argument
108 static struct job *jobtab; /* array of jobs */
111 static struct job *bgjob = NULL; /* last background process */
113 static struct job *jobmru; /* most recently used job list */
124 static void restartjob(struct job *);
126 static void freejob(struct job *);
127 static int waitcmdloop(struct job *);
128 static struct job *getjob_nonotfound(const char *);
129 static struct job *getjob(const char *);
131 static pid_t dowait(int, struct job *);
136 static void setcurjob(struct job *);
137 static void deljob(struct job *);
138 static struct job *getcurjob(struct job *);
140 static int getjobstatus(const struct job *);
141 static void printjobcmd(struct job *);
142 static void showjob(struct job *, int);
146 * Turn job control on and off.
166 out2fmt_flush("sh: can't access tty; job control turned off\n"); in jobctl_notty()
223 } else { /* turning job control off */ in setjobctl()
243 struct job *jp; in fgcmd()
250 error("job not created under job control"); in fgcmd()
268 struct job *jp; in bgcmd()
274 error("job not created under job control"); in bgcmd()
287 restartjob(struct job *jp) in restartjob()
338 static int getjobstatus(const struct job *jp) in getjobstatus()
353 printjobcmd(struct job *jp) in printjobcmd()
367 showjob(struct job *jp, int mode) in showjob()
373 struct job *j; in showjob()
466 * If the shell is interrupted in the process of creating a job, the
467 * result may be a job structure containing zero processes. Such structures
475 struct job *jp; in showjobs()
504 * Mark a job structure as unused.
508 freejob(struct job *jp) in freejob()
534 struct job *job; in waitcmd() local
542 job = getjob_nonotfound(*argptr); in waitcmd()
543 if (job == NULL) in waitcmd()
546 retval = waitcmdloop(job); in waitcmd()
554 waitcmdloop(struct job *job) in waitcmdloop() argument
557 struct job *jp; in waitcmdloop()
565 if (job != NULL) { in waitcmdloop()
566 if (job->state == JOBDONE) { in waitcmdloop()
567 status = getjobstatus(job); in waitcmdloop()
572 if (! iflag || ! job->changed) in waitcmdloop()
573 freejob(job); in waitcmdloop()
575 job->remembered = 0; in waitcmdloop()
576 if (job == bgjob) in waitcmdloop()
602 } while (dowait(DOWAIT_BLOCK | DOWAIT_SIG, (struct job *)NULL) != -1); in waitcmdloop()
614 struct job *jp; in jobidcmd()
629 * Convert a job name to a job structure.
632 static struct job *
636 struct job *found, *jp; in getjob_nonotfound()
645 error("No current job"); in getjob_nonotfound()
658 error("No current job"); in getjob_nonotfound()
663 error("No previous job"); in getjob_nonotfound()
705 static struct job *
708 struct job *jp; in getjob()
712 error("No such job: %s", name); in getjob()
720 struct job *jp; in killjob()
740 * Return a new job structure,
743 struct job *
747 struct job *jp; in makejob()
812 setcurjob(struct job *cj) in setcurjob()
814 struct job *jp, *prev; in setcurjob()
832 deljob(struct job *j) in deljob()
834 struct job *jp, *prev; in deljob()
848 * Return the most recently used job that isn't `nj', and preferably one
851 static struct job *
852 getcurjob(struct job *nj) in getcurjob()
854 struct job *jp; in getcurjob()
860 /* Otherwise the most recently used job that isn't `nj' */ in getcurjob()
871 * Fork of a subshell. If we are doing job control, give the subshell its
872 * own process group. Jp is a job structure that the job is to be added to.
878 * process group even if job control is on.
880 * When job control is turned off, background processes have their standard
886 forkshell(struct job *jp, union node *n, int mode) in forkshell()
904 struct job *p; in forkshell()
917 jobctl = 0; /* do job control only in root shell */ in forkshell()
1005 vforkexecshell(struct job *jp, char **argv, char **envp, const char *path, int idx, int pip[2]) in vforkexecshell()
1056 * Wait for job to finish.
1058 * Under job control we have the problem that while a child process is
1061 * active user may be hard to kill. With job control turned off, an
1075 waitforjob(struct job *jp, int *signaled) in waitforjob()
1135 dowait(int mode, struct job *job) in dowait() argument
1142 struct job *jp; in dowait()
1143 struct job *thisjob; in dowait()
1152 TRACE(("dowait(%d, %p) called\n", mode, job)); in dowait()
1189 if (pid == -1 && errno == ECHILD && job != NULL) in dowait()
1190 job->state = JOBDONE; in dowait()
1228 TRACE(("Job %td: changing state from %d to %d\n", jp - jobtab + 1, jp->state, state)); in dowait()
1230 if (jp != job) { in dowait()
1246 else if ((!rootshell || !iflag || thisjob == job) && in dowait()
1267 TRACE(("Not printing status, rootshell=%d, job=%p\n", rootshell, job)); in dowait()
1283 struct job *jp; in stoppedjobs()