Home | History | Annotate | Download | only in src

Lines Matching refs:job

52 #define JP_MEDIUM	2	/* print [job-num] -/+ command */
53 #define JP_LONG 3 /* print [job-num] -/+ pid command */
60 /* Job.flags values */
61 #define JF_STARTED 0x001 /* set when all processes in job are started */
62 #define JF_WAITING 0x002 /* set if j_waitj() is waiting on job */
74 typedef struct job Job;
75 struct job {
76 Job *next; /* next job in list */
79 struct timeval systime; /* system time used by job */
80 struct timeval usrtime; /* user time used by job */
81 pid_t pgrp; /* process group of job */
82 pid_t ppid; /* pid of process that forked job */
83 int job; /* job number: %n */
85 volatile int state; /* job state */
99 #define JW_STOPPEDWAIT 0x04 /* wait even if job stopped */
104 #define JL_NOSUCH 1 /* no such job */
106 #define JL_INVALID 3 /* non-pid, non-% job id */
110 "no such job",
112 "argument must be %job or process id",
116 static Job *job_list; /* job list */
117 static Job *last_job;
118 static Job *async_job;
129 /* held_sigchld is set if sigchld occurs before a job is completely started */
140 static void j_set_async(Job *);
141 static void j_startjob(Job *);
142 static int j_waitj(Job *, int, const char *);
144 static void j_print(Job *, int, struct shf *);
145 static Job *j_lookup(const char *, int *);
146 static Job *new_job(void);
148 static void check_job(Job *);
149 static void put_job(Job *, int);
150 static void remove_job(Job *, const char *);
151 static int kill_job(Job *, int);
153 /* initialise job control */
224 /* job cleanup before shell exit */
229 Job *j;
278 /* turn job control on or off according to Flag(FMONITOR) */
295 /* wait to be given tty (POSIX.1, B.2, job control) */
332 "won't have full job control");
389 Job *j;
405 /* no SIGCHLDs while messing with job and process lists */
427 /* fills in j->job */
473 /* job control set up */
563 /* last process in a job */
570 coproc.job = (void *)j;
575 shf_fprintf(shl_out, "[%d]", j->job);
593 /* start the last job: only used for $(command) jobs */
614 /* wait for last job: only used for $(command) jobs */
619 Job *j;
629 warningf(true, "%s: %s", "waitlast", "no last job");
653 Job *j;
664 * wait for an unspecified job - always returns 0, so
678 /* don't report normal job completion */
709 /* kill (built-in) a job */
713 Job *j;
758 Job *j;
774 bi_errorf("job not job-controlled");
779 shprintf("[%d] ", j->job);
801 /* attach tty to job */
840 bi_errorf("%s %s %s", "can't continue job",
859 Job *j;
889 Job *j, *tmp;
941 Job *j, *tmp;
953 * Remove job after doing reports so there aren't
970 /* Return pid of last process in last asynchronous job */
996 j_set_async(Job *j)
998 Job *jl, *oldest;
1003 internal_warningf("%s: %s", "j_async", "job not started");
1028 * Start a job: set STARTED, check for held signals and set j->last_proc
1033 j_startjob(Job *j)
1045 /* Don't call j_sigchld() as it may remove job... */
1052 * wait for job to complete or change state
1057 j_waitj(Job *j,
1065 * No auto-notify on the job we are waiting on.
1103 * when the job is foregrounded. This is to
1127 * Only restore tty settings if job was originally
1141 * Don't use tty mode if job is stopped and
1158 * If it looks like user hit ^C to kill a job, pretend we got
1230 * SIGCHLD handler to reap children and update job states
1240 Job *j;
1248 * Don't wait for any processes if a job is partially started.
1277 /* find job and process structures for this pid */
1308 /* check to see if entire job is done */
1320 * from j_sigchld()). If no processes are running, the job status
1321 * and state are updated, asynchronous job notification is done and,
1322 * if unneeded, the job is removed.
1327 check_job(Job *j)
1334 internal_warningf("check_job: job started (flags 0x%x)",
1360 if (coproc.job == j) {
1361 coproc.job = NULL;
1366 * do "if job == 0 && write >= 0, close write".
1398 * Can't call j_notify() as it removes jobs. The job
1399 * must stay in the job list as j_waitj() may be
1400 * running with this job.
1417 j->job = -1;
1425 * Print job status in either short, medium or long format.
1430 j_print(Job *j, int how, struct shf *shf)
1452 filler = j->job > 10 ? "\n " : "\n ";
1498 shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
1538 * Convert % sequence to job
1542 static Job *
1545 Job *j, *last_match;
1548 int job = 0;
1551 getn(cp, &job);
1554 if (j->last_proc && j->last_proc->pid == job)
1561 if (j->pgrp && j->pgrp == job)
1587 getn(cp, &job);
1589 if (j->job == job)
1632 static Job *free_jobs;
1636 * allocate a new job and fill in the job number.
1640 static Job *
1644 Job *newj, *j;
1650 newj = alloc(sizeof(Job), APERM);
1654 for (j = job_list; j && j->job != i; j = j->next)
1659 newj->job = i;
1684 * Take job out of job_list and put old structures into free list.
1690 remove_job(Job *j, const char *where)
1693 Job **prev, *curr;
1700 internal_warningf("remove_job: job %s (%s)", "not found", where);
1731 put_job(Job *j, int where)
1733 Job **prev, *curr;
1735 /* Remove job from list (if there) */
1762 * nuke a job (called when unable to start full job).
1767 kill_job(Job *j, int sig)