Lines Matching refs:job

4  * Process and job control
109 #define JP_MEDIUM 2 /* print [job-num] -/+ command */
110 #define JP_LONG 3 /* print [job-num] -/+ pid command */
118 #define JF_STARTED 0x001 /* set when all processes in job are started */
119 #define JF_WAITING 0x002 /* set if j_waitj() is waiting on job */
131 typedef struct job Job;
132 struct job {
133 Job *next; /* next job in list */
134 int job; /* job number: %n */
136 int state; /* job state */
138 pid_t pgrp; /* process group of job */
139 pid_t ppid; /* pid of process that forked job */
141 clock_t systime; /* system time used by job */
142 clock_t usrtime; /* user time used by job */
158 #define JW_STOPPEDWAIT 0x04 /* wait even if job stopped */
162 #define JL_NOSUCH 1 /* no such job */
164 #define JL_INVALID 3 /* non-pid, non-% job id */
168 "no such job",
170 "argument must be %job or process id",
173 clock_t j_systime, j_usrtime; /* user and system time of last j_waitjed job */
175 static Job *job_list; /* job list */
185 /* held_sigchld is set if sigchld occurs before a job is completely started */
225 /* initialize job control */
275 /* job cleanup before shell exit */
332 /* turn job control on or off according to Flag(FMONITOR) */
354 /* wait to be given tty (POSIX.1, B.2, job control) */
401 warningf(false, "warning: won't have full job control");
450 /* no SIGCHLD's while messing with job and process lists */
478 j = new_job(); /* fills in j->job */
527 /* job control set up */
642 if (!(flags & XPIPEO)) { /* last process in a job */
654 coproc.job = (void *) j; /* j using co-process input */
660 shf_fprintf(shl_out, "[%d]", j->job);
675 /* start the last job: only used for `command` jobs */
691 /* wait for last job: only used for `command` jobs */
704 warningf(true, "waitlast: no last job");
735 /* wait for an unspecified job - always returns 0, so
747 /* don't report normal job completion */
771 /* kill (built-in) a job */
835 bi_errorf("job not job-controlled");
840 shprintf("[%d] ", j->job);
861 /* attach tty to job */
903 bi_errorf("cannot continue job %s: %s",
1010 /* Remove job after doing reports so there aren't
1025 /* Return pid of last process in last asynchronous job */
1054 internal_errorf(0, "j_async: job not started");
1077 /* Start a job: set STARTED, check for held signals and set j->last_proc
1100 /* Don't call j_sigchld() as it may remove job... */
1106 * wait for job to complete or change state
1119 * No auto-notify on the job we are waiting on.
1154 * when the job is foregrounded. This is to
1179 /* Only restore tty settings if job was originally
1194 /* Don't use tty mode if job is stopped and
1210 /* If it looks like user hit ^C to kill a job, pretend we got
1240 /* SIGCHLD handler to reap children and update job states
1255 /* Don't wait for any processes if a job is partially started.
1275 /* find job and process structures for this pid */
1304 check_job(j); /* check to see if entire job is done */
1315 * from j_sigchld()). If no processes are running, the job status
1316 * and state are updated, asynchronous job notification is done and,
1317 * if unneeded, the job is removed.
1330 internal_errorf(0, "check_job: job started (flags 0x%x)",
1365 if (coproc.job == j) {
1366 coproc.job = (void *) 0;
1370 * do "if job == 0 && write >= 0, close write".
1402 /* Can't call j_notify() as it removes jobs. The job
1403 * must stay in the job list as j_waitj() may be
1404 * running with this job.
1418 j->job = -1;
1426 * Print job status in either short, medium or long format.
1455 filler = j->job > 10 ? "\n " : "\n ";
1498 shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
1537 /* Convert % sequence to job
1548 int len, job = 0;
1551 job = atoi(cp);
1554 if (j->last_proc && j->last_proc->pid == job)
1560 if (j->pgrp && j->pgrp == job)
1586 job = atoi(cp);
1588 if (j->job == job)
1632 /* allocate a new job and fill in the job number.
1650 for (j = job_list; j && j->job != i; j = j->next)
1655 newj->job = i;
1678 /* Take job out of job_list and put old structures into free list.
1696 internal_errorf(0, "remove_job: job not found (%s)", where);
1732 /* Remove job from list (if there) */
1758 /* nuke a job (called when unable to start full job).