xref: /original-bsd/bin/sh/jobs.h (revision b3c06cab)
1 /*-
2  * Copyright (c) 1991, 1993
3  *	The Regents of the University of California.  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	8.2 (Berkeley) 05/04/95
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 extern int job_warning;		/* user was warned about stopped jobs */
53 
54 void setjobctl __P((int));
55 int fgcmd __P((int, char **));
56 int bgcmd __P((int, char **));
57 int jobscmd __P((int, char **));
58 void showjobs __P((int));
59 int waitcmd __P((int, char **));
60 int jobidcmd __P((int, char **));
61 struct job *makejob __P((union node *, int));
62 int forkshell __P((struct job *, union node *, int));
63 int waitforjob __P((struct job *));
64 int stoppedjobs __P((void));
65 char *commandtext __P((union node *));
66 
67 #if ! JOBS
68 #define setjobctl(on)	/* do nothing */
69 #endif
70