| 1 | /*- |
| 2 | * Copyright (c) 1991 The Regents of the University of California. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This code is derived from software contributed to Berkeley by |
| 6 | * Kenneth Almquist. |
| 7 | * |
| 8 | * %sccs.include.redist.c% |
| 9 | * |
| 10 | * @(#)jobs.h 5.1 (Berkeley) %G% |
| 11 | */ |
| 12 | |
| 13 | /* Mode argument to forkshell. Don't change FORK_FG or FORK_BG. */ |
| 14 | #define FORK_FG 0 |
| 15 | #define FORK_BG 1 |
| 16 | #define FORK_NOJOB 2 |
| 17 | |
| 18 | |
| 19 | /* |
| 20 | * A job structure contains information about a job. A job is either a |
| 21 | * single process or a set of processes contained in a pipeline. In the |
| 22 | * latter case, pidlist will be non-NULL, and will point to a -1 terminated |
| 23 | * array of pids. |
| 24 | */ |
| 25 | |
| 26 | struct procstat { |
| 27 | short pid; /* process id */ |
| 28 | short status; /* status flags (defined above) */ |
| 29 | char *cmd; /* text of command being run */ |
| 30 | }; |
| 31 | |
| 32 | |
| 33 | /* states */ |
| 34 | #define JOBSTOPPED 1 /* all procs are stopped */ |
| 35 | #define JOBDONE 2 /* all procs are completed */ |
| 36 | |
| 37 | |
| 38 | struct job { |
| 39 | struct procstat ps0; /* status of process */ |
| 40 | struct procstat *ps; /* status or processes when more than one */ |
| 41 | short nprocs; /* number of processes */ |
| 42 | short pgrp; /* process group of this job */ |
| 43 | char state; /* true if job is finished */ |
| 44 | char used; /* true if this entry is in used */ |
| 45 | char changed; /* true if status has changed */ |
| 46 | #if JOBS |
| 47 | char jobctl; /* job running under job control */ |
| 48 | #endif |
| 49 | }; |
| 50 | |
| 51 | extern short backgndpid; /* pid of last background process */ |
| 52 | |
| 53 | |
| 54 | #ifdef __STDC__ |
| 55 | void setjobctl(int); |
| 56 | void showjobs(int); |
| 57 | struct job *makejob(union node *, int); |
| 58 | int forkshell(struct job *, union node *, int); |
| 59 | int waitforjob(struct job *); |
| 60 | #else |
| 61 | void setjobctl(); |
| 62 | void showjobs(); |
| 63 | struct job *makejob(); |
| 64 | int forkshell(); |
| 65 | int waitforjob(); |
| 66 | #endif |
| 67 | |
| 68 | #if ! JOBS |
| 69 | #define setjobctl(on) /* do nothing */ |
| 70 | #endif |