386BSD 0.1 development
[unix-history] / usr / src / bin / csh / proc.h
CommitLineData
ef09701e
WJ
1/*-
2 * Copyright (c) 1980, 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)proc.h 5.6 (Berkeley) 6/25/91
34 */
35
36/*
37 * Structure for each process the shell knows about:
38 * allocated and filled by pcreate.
39 * flushed by pflush; freeing always happens at top level
40 * so the interrupt level has less to worry about.
41 * processes are related to "friends" when in a pipeline;
42 * p_friends links makes a circular list of such jobs
43 */
44struct process {
45 struct process *p_next; /* next in global "proclist" */
46 struct process *p_friends; /* next in job list (or self) */
47 struct directory *p_cwd; /* cwd of the job (only in head) */
48 short unsigned p_flags; /* various job status flags */
49 char p_reason; /* reason for entering this state */
50 int p_index; /* shorthand job index */
51 int p_pid;
52 int p_jobid; /* pid of job leader */
53 /* if a job is stopped/background p_jobid gives its pgrp */
54 struct timeval p_btime; /* begin time */
55 struct timeval p_etime; /* end time */
56 struct rusage p_rusage;
57 Char *p_command; /* first PMAXLEN chars of command */
58};
59
60/* flag values for p_flags */
61#define PRUNNING (1<<0) /* running */
62#define PSTOPPED (1<<1) /* stopped */
63#define PNEXITED (1<<2) /* normally exited */
64#define PAEXITED (1<<3) /* abnormally exited */
65#define PSIGNALED (1<<4) /* terminated by a signal != SIGINT */
66
67#define PALLSTATES (PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED)
68#define PNOTIFY (1<<5) /* notify async when done */
69#define PTIME (1<<6) /* job times should be printed */
70#define PAWAITED (1<<7) /* top level is waiting for it */
71#define PFOREGND (1<<8) /* started in shells pgrp */
72#define PDUMPED (1<<9) /* process dumped core */
73#define PDIAG (1<<10) /* diagnostic output also piped out */
74#define PPOU (1<<11) /* piped output */
75#define PREPORTED (1<<12) /* status has been reported */
76#define PINTERRUPTED (1<<13) /* job stopped via interrupt signal */
77#define PPTIME (1<<14) /* time individual process */
78#define PNEEDNOTE (1<<15) /* notify as soon as practical */
79
80#define PMAXLEN 80
81
82/* defines for arguments to pprint */
83#define NUMBER 01
84#define NAME 02
85#define REASON 04
86#define AMPERSAND 010
87#define FANCY 020
88#define SHELLDIR 040 /* print shell's dir if not the same */
89#define JOBDIR 0100 /* print job's dir if not the same */
90#define AREASON 0200
91
92struct process proclist; /* list head of all processes */
93bool pnoprocesses; /* pchild found nothing to wait for */
94
95struct process *pholdjob; /* one level stack of current jobs */
96
97struct process *pcurrjob; /* current job */
98struct process *pcurrent; /* current job in table */
99struct process *pprevious; /* previous job in table */
100
101int pmaxindex; /* current maximum job index */