xref: /original-bsd/local/toolchest/ksh/sh/jobs.h (revision 7a824e3d)
1 /*
2 
3  *      Copyright (c) 1984, 1985, 1986 AT&T
4  *      All Rights Reserved
5 
6  *      THIS IS UNPUBLISHED PROPRIETARY SOURCE
7  *      CODE OF AT&T.
8  *      The copyright notice above does not
9  *      evidence any actual or intended
10  *      publication of such source code.
11 
12  */
13 /* @(#)jobs.h	1.1 */
14 
15 /*
16  *	UNIX shell
17  *	S. R. Bourne
18  *	rewritten by David Korn
19  *
20  */
21 #ifdef JOBS
22 
23 # if BSD || RT
24 # include	<sgtty.h>
25 # else
26 #  ifndef CBUNIX
27 #  include	<termio.h>
28 #  define _IOCTL_
29 #  endif /* CBUNIX */
30 # endif
31 
32 # ifndef RT
33 #  ifndef _IOCTL_
34 #  include	<sys/ioctl.h>
35 # endif /* _IOCTL_ */
36 # endif /* RT */
37 
38 # if u370 || uts
39 # define MAXJ	75
40 # else
41 # define MAXJ	32
42 # endif /* u370 */
43 
44 /* JBYTES is the number of char's needed for MAXJ bits */
45 #define JBYTES	(1+((MAXJ-1)/(8)))
46 
47 #endif	/* JOBS */
48 
49 
50 struct process
51 {
52 #ifdef JOBS
53 	struct process *p_next;	/* next process structure */
54 #endif	/* JOBS */
55 	int	p_pid;
56 #ifdef JOBS
57 	int	p_pgrp;			/* process group */
58 	unsigned char	p_job;		/* job number of process */
59 	unsigned char	p_flag;		/* flags - see below */
60 	unsigned short	p_sig;		/* signal number */
61 	long	p_name;			/* offset into history file for command */
62 # if BSD || RT
63 	struct sgttyb p_stty;		/* terminal state for job */
64 # else
65 #  ifdef CBUNIX
66 	struct ttiocb p_stty;
67 	struct termcb p_sterm;
68 #  else
69 	struct termio p_stty;		/* terminal state for job */
70 #  endif /* CBUNIX */
71 # endif /* BSD */
72 #endif	/* JOBS */
73 };
74 
75 #ifdef JOBS
76 /* Process states */
77 
78 #define P_RUNNING	1
79 #define P_STOPPED	2
80 #define P_NOTIFY	4
81 #define P_WAITED	8
82 #define P_STTY		16
83 #define P_PIPEJOB	32
84 #define P_COREDUMP	64
85 
86 struct jobs
87 {
88 	int		cur_pgrp;
89 	int		mypid;
90 	short		cur_job;
91 	short		j_flag;
92 	int		p_numpost;	/* number of posted jobs */
93 	int		p_numrun;	/* number of running jobs */
94 	struct process	*p_pwlist;	/* head of process list */
95 	unsigned char	p_freejobs[JBYTES];	/* free jobs numbers */
96 # ifdef SXT
97 	int		pipe[2];	/* pipe used for synchronization */
98 	int		maxjob;		/* maximum number of channels */
99 # endif /* SXT */
100 };
101 
102 extern struct jobs jobstat;
103 
104 #define	J_PIPE		1	/* set when setting up a pipeline */
105 extern MSG	kill_usage;
106 extern MSG	bkill;
107 extern MSG	j_Done;
108 extern MSG	j_Running;
109 extern MSG	j_amp;
110 extern MSG	j_coredump;
111 extern MSG	j_cpid;
112 extern MSG	j_job;
113 extern MSG	j_kill;
114 extern MSG	j_no_jctl;
115 extern MSG	j_newtty;
116 extern MSG	j_no_proc;
117 extern MSG	j_no_job;
118 extern MSG	j_no_start;
119 extern MSG	j_not_tty;
120 extern MSG	j_oldtty;
121 extern MSG	j_perm;
122 extern MSG	j_running;
123 extern MSG	j_space;
124 extern MSG	j_terminate;
125 #endif	/* JOBS */
126 extern int parent;
127 extern char	*sysmsg[];
128