Home | History | Annotate | Download | only in src

Lines Matching refs:Job

54 #define JP_MEDIUM	2	/* print [job-num] -/+ command */
55 #define JP_LONG 3 /* print [job-num] -/+ pid command */
62 /* Job.flags values */
63 #define JF_STARTED 0x001 /* set when all processes in job are started */
64 #define JF_WAITING 0x002 /* set if j_waitj() is waiting on job */
76 typedef struct job Job;
77 struct job {
78 Job *next; /* next job in list */
81 struct timeval systime; /* system time used by job */
82 struct timeval usrtime; /* user time used by job */
83 pid_t pgrp; /* process group of job */
84 pid_t ppid; /* pid of process that forked job */
85 int job; /* job number: %n */
87 volatile int state; /* job state */
101 #define JW_STOPPEDWAIT 0x04 /* wait even if job stopped */
105 #define JL_NOSUCH 0 /* no such job */
107 #define JL_INVALID 2 /* non-pid, non-% job id */
110 "no such job",
112 "argument must be %job or process id"
115 static Job *job_list; /* job list */
116 static Job *last_job;
117 static Job *async_job;
128 /* held_sigchld is set if sigchld occurs before a job is completely started */
139 static void j_set_async(Job *);
140 static void j_startjob(Job *);
141 static int j_waitj(Job *, int, const char *);
143 static void j_print(Job *, int, struct shf *);
144 static Job *j_lookup(const char *, int *);
145 static Job *new_job(void);
147 static void check_job(Job *);
148 static void put_job(Job *, int);
149 static void remove_job(Job *, const char *);
150 static int kill_job(Job *, int);
155 /* initialise job control */
276 /* job cleanup before shell exit */
281 Job *j;
330 /* turn job control on or off according to Flag(FMONITOR) */
347 /* wait to be given tty (POSIX.1, B.2, job control) */
385 "won't have full job control");
440 Job *j;
456 /* no SIGCHLDs while messing with job and process lists */
477 /* fills in j->job */
523 /* job control set up */
614 /* last process in a job */
621 coproc.job = (void *)j;
626 shf_fprintf(shl_out, "[%d]", j->job);
644 /* start the last job: only used for $(command) jobs */
665 /* wait for last job: only used for $(command) jobs */
670 Job *j;
680 warningf(true, Tf_sD_s, "waitlast", "no last job");
704 Job *j;
715 * wait for an unspecified job - always returns 0, so
729 /* don't report normal job completion */
760 /* kill (built-in) a job */
764 Job *j;
809 Job *j;
825 bi_errorf("job not job-controlled");
830 shprintf("[%d] ", j->job);
852 /* attach tty to job */
891 bi_errorf(Tf_s_sD_s, "can't continue job",
910 Job *j;
940 Job *j, *tmp;
992 Job *j, *tmp;
1004 * Remove job after doing reports so there aren't
1021 /* Return pid of last process in last asynchronous job */
1047 j_set_async(Job *j)
1049 Job *jl, *oldest;
1079 * Start a job: set STARTED, check for held signals and set j->last_proc
1084 j_startjob(Job *j)
1096 /* Don't call j_sigchld() as it may remove job... */
1103 * wait for job to complete or change state
1108 j_waitj(Job *j,
1120 * No auto-notify on the job we are waiting on.
1165 * when the job is foregrounded. This is to
1189 * Only restore tty settings if job was originally
1203 * Don't use tty mode if job is stopped and
1220 * If it looks like user hit ^C to kill a job, pretend we got
1302 * SIGCHLD handler to reap children and update job states
1311 Job *j;
1325 * Don't wait for any processes if a job is partially started.
1358 /* find job and process structures for this pid */
1396 /* check to see if entire job is done */
1414 * from j_sigchld()). If no processes are running, the job status
1415 * and state are updated, asynchronous job notification is done and,
1416 * if unneeded, the job is removed.
1421 check_job(Job *j)
1428 internal_warningf("check_job: job started (flags 0x%X)",
1454 if (coproc.job == j) {
1455 coproc.job = NULL;
1460 * do "if job == 0 && write >= 0, close write".
1492 * Can't call j_notify() as it removes jobs. The job
1493 * must stay in the job list as j_waitj() may be
1494 * running with this job.
1511 j->job = -1;
1519 * Print job status in either short, medium or long format.
1524 j_print(Job *j, int how, struct shf *shf)
1546 filler = j->job > 10 ? "\n " : "\n ";
1602 shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
1642 * Convert % sequence to job
1646 static Job *
1649 Job *j, *last_match;
1652 int job = 0;
1654 if (ksh_isdigit(*cp) && getn(cp, &job)) {
1657 if (j->last_proc && j->last_proc->pid == job)
1664 if (j->pgrp && j->pgrp == job)
1689 if (!getn(cp, &job))
1692 if (j->job == job)
1736 static Job *free_jobs;
1740 * allocate a new job and fill in the job number.
1744 static Job *
1748 Job *newj, *j;
1754 newj = alloc(sizeof(Job), APERM);
1758 for (j = job_list; j && j->job != i; j = j->next)
1763 newj->job = i;
1788 * Take job out of job_list and put old structures into free list.
1794 remove_job(Job *j, const char *where)
1797 Job **prev, *curr;
1806 internal_warningf("remove_job: job %s (%s)", Tnot_found, where);
1837 put_job(Job *j, int where)
1839 Job **prev, *curr;
1841 /* Remove job from list (if there) */
1870 * nuke a job (called when unable to start full job).
1875 kill_job(Job *j, int sig)