Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / cmd / ksh93 / include / jobs.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: jobs.h /main/3 1995/11/01 16:40:45 rswiston $ */
24 /***************************************************************
25 *                                                              *
26 *                      AT&T - PROPRIETARY                      *
27 *                                                              *
28 *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
29 *                    AT&T BELL LABORATORIES                    *
30 *         AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN         *
31 *            ACCORDANCE WITH APPLICABLE AGREEMENTS             *
32 *                                                              *
33 *                Copyright (c) 1995 AT&T Corp.                 *
34 *              Unpublished & Not for Publication               *
35 *                     All Rights Reserved                      *
36 *                                                              *
37 *       The copyright notice above does not evidence any       *
38 *      actual or intended publication of such source code      *
39 *                                                              *
40 *               This software was created by the               *
41 *           Advanced Software Technology Department            *
42 *                    AT&T Bell Laboratories                    *
43 *                                                              *
44 *               For further information contact                *
45 *                    {research,attmail}!dgk                    *
46 *                                                              *
47 ***************************************************************/
48
49 /* : : generated by proto : : */
50                   
51 #ifndef JOB_NFLAG
52 #if !defined(__PROTO__)
53 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
54 #if defined(__cplusplus)
55 #define __MANGLE__      "C"
56 #else
57 #define __MANGLE__
58 #endif
59 #define __STDARG__
60 #define __PROTO__(x)    x
61 #define __OTORP__(x)
62 #define __PARAM__(n,o)  n
63 #if !defined(__STDC__) && !defined(__cplusplus)
64 #if !defined(c_plusplus)
65 #define const
66 #endif
67 #define signed
68 #define void            int
69 #define volatile
70 #define __V_            char
71 #else
72 #define __V_            void
73 #endif
74 #else
75 #define __PROTO__(x)    ()
76 #define __OTORP__(x)    x
77 #define __PARAM__(n,o)  o
78 #define __MANGLE__
79 #define __V_            char
80 #define const
81 #define signed
82 #define void            int
83 #define volatile
84 #endif
85 #if defined(__cplusplus) || defined(c_plusplus)
86 #define __VARARG__      ...
87 #else
88 #define __VARARG__
89 #endif
90 #if defined(__STDARG__)
91 #define __VA_START__(p,a)       va_start(p,a)
92 #else
93 #define __VA_START__(p,a)       va_start(p)
94 #endif
95 #endif
96
97 /*
98  *      Interface to job control for shell
99  *      written by David Korn
100  *
101  */
102
103 #define JOBTTY  2
104
105 #include        <ast.h>
106 #include        <sfio.h>
107 #ifndef SIGINT
108 #   include     <signal.h>
109 #endif /* !SIGINT */
110 #include        "FEATURE/options"
111
112 #undef JOBS
113 #if defined(SIGCLD) && !defined(SIGCHLD)
114 #   define SIGCHLD      SIGCLD
115 #endif
116 #ifdef SIGCHLD
117 #   define JOBS 1
118 #   include     "terminal.h"
119 #   ifdef FIOLOOKLD
120         /* Ninth edition */
121         extern __MANGLE__ int tty_ld, ntty_ld;
122 #       define OTTYDISC tty_ld
123 #       define NTTYDISC ntty_ld
124 #   endif       /* FIOLOOKLD */
125 #else
126 #   undef SIGTSTP
127 #   undef SH_MONITOR
128 #   define SH_MONITOR   0
129 #   define job_set(x)
130 #   define job_reset(x)
131 #endif
132
133 struct process
134 {
135         struct process *p_nxtjob;       /* next job structure */
136         struct process *p_nxtproc;      /* next process in current job */
137         pid_t           p_pid;          /* process id */
138         pid_t           p_pgrp;         /* process group */
139         pid_t           p_fgrp;         /* process group when stopped */
140         short           p_job;          /* job number of process */
141         unsigned short  p_exit;         /* exit value or signal number */
142         unsigned char   p_flag;         /* flags - see below */
143         int             p_env;          /* subshell environment number */
144 #ifdef JOBS
145         off_t           p_name;         /* history file offset for command */
146         struct termios  p_stty;         /* terminal state for job */
147 #endif /* JOBS */
148 };
149
150 struct jobs
151 {
152         struct process  *pwlist;        /* head of process list */
153         pid_t           curpgid;        /* current process gid id */
154         pid_t           parent;         /* set by fork() */
155         pid_t           mypid;          /* process id of shell */
156         pid_t           mypgid;         /* process group id of shell */
157         pid_t           mytgid;         /* terminal group id of shell */
158         int             numpost;        /* number of posted jobs */
159         short           fd;             /* tty descriptor number */
160 #ifdef JOBS
161         int             suspend;        /* suspend character */
162         int             linedisc;       /* line dicipline */
163 #endif /* JOBS */
164         char            in_critical;    /* set when in critical region */
165         char            jobcontrol;     /* turned on for real job control */
166         char            waitsafe;       /* wait will not block */
167         char            waitall;        /* wait for all jobs in pipe */
168         char            toclear;        /* job table needs clearing */
169         unsigned char   *freejobs;      /* free jobs numbers */
170 };
171
172 /* flags for joblist */
173 #define JOB_LFLAG       1
174 #define JOB_NFLAG       2
175 #define JOB_PFLAG       4
176 #define JOB_NLFLAG      8
177
178 extern __MANGLE__ struct jobs job;
179
180 #ifdef JOBS
181 extern __MANGLE__ const char    e_jobusage[];
182 extern __MANGLE__ const char    e_kill[];
183 extern __MANGLE__ const char    e_done[];
184 extern __MANGLE__ const char    e_running[];
185 extern __MANGLE__ const char    e_coredump[];
186 extern __MANGLE__ const char    e_killcolon[];
187 extern __MANGLE__ const char    e_no_proc[];
188 extern __MANGLE__ const char    e_no_job[];
189 extern __MANGLE__ const char    e_jobsrunning[];
190 extern __MANGLE__ const char    e_nlspace[];
191 extern __MANGLE__ const char    e_access[];
192 extern __MANGLE__ const char    e_terminate[];
193 extern __MANGLE__ const char    e_no_jctl[];
194 #ifdef SIGTSTP
195    extern __MANGLE__ const char e_no_start[];
196 #endif /* SIGTSTP */
197 #ifdef NTTYDISC
198    extern __MANGLE__ const char e_newtty[];
199    extern __MANGLE__ const char e_oldtty[];
200 #endif /* NTTYDISC */
201 #endif  /* JOBS */
202
203 /*
204  * The following are defined in jobs.c
205  */
206
207 extern __MANGLE__ void  job_clear __PROTO__((void));
208 extern __MANGLE__ void  job_bwait __PROTO__((char**));
209 extern __MANGLE__ int   job_walk __PROTO__((Sfio_t*,int(*)(struct process*,int),int,char*[]));
210 extern __MANGLE__ int   job_kill __PROTO__((struct process*,int));
211 extern __MANGLE__ void  job_wait __PROTO__((pid_t));
212 extern __MANGLE__ int   job_post __PROTO__((pid_t,pid_t));
213 extern __MANGLE__ int   job_chksave __PROTO__((pid_t));
214 #ifdef JOBS
215         extern __MANGLE__ void  job_init __PROTO__((int));
216         extern __MANGLE__ int   job_close __PROTO__((void));
217         extern __MANGLE__ int   job_list __PROTO__((struct process*,int));
218         extern __MANGLE__ int   job_terminate __PROTO__((struct process*,int));
219         extern __MANGLE__ int   job_switch __PROTO__((struct process*,int));
220 #else
221 #       define job_init(flag)
222 #       define job_close()      (0)
223 #endif  /* JOBS */
224
225
226 #endif /* !JOB_NFLAG */