xref: /freebsd/contrib/tcsh/sh.proc.h (revision 9122aeeaa60ee2a1381ea935d749194b32940e7a)
1c80476e4SDavid E. O'Brien /*
2c80476e4SDavid E. O'Brien  * sh.proc.h: Process data structures and variables
3c80476e4SDavid E. O'Brien  */
4c80476e4SDavid E. O'Brien /*-
5c80476e4SDavid E. O'Brien  * Copyright (c) 1980, 1991 The Regents of the University of California.
6c80476e4SDavid E. O'Brien  * All rights reserved.
7c80476e4SDavid E. O'Brien  *
8c80476e4SDavid E. O'Brien  * Redistribution and use in source and binary forms, with or without
9c80476e4SDavid E. O'Brien  * modification, are permitted provided that the following conditions
10c80476e4SDavid E. O'Brien  * are met:
11c80476e4SDavid E. O'Brien  * 1. Redistributions of source code must retain the above copyright
12c80476e4SDavid E. O'Brien  *    notice, this list of conditions and the following disclaimer.
13c80476e4SDavid E. O'Brien  * 2. Redistributions in binary form must reproduce the above copyright
14c80476e4SDavid E. O'Brien  *    notice, this list of conditions and the following disclaimer in the
15c80476e4SDavid E. O'Brien  *    documentation and/or other materials provided with the distribution.
1629301572SMark Peek  * 3. Neither the name of the University nor the names of its contributors
17c80476e4SDavid E. O'Brien  *    may be used to endorse or promote products derived from this software
18c80476e4SDavid E. O'Brien  *    without specific prior written permission.
19c80476e4SDavid E. O'Brien  *
20c80476e4SDavid E. O'Brien  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21c80476e4SDavid E. O'Brien  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22c80476e4SDavid E. O'Brien  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23c80476e4SDavid E. O'Brien  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24c80476e4SDavid E. O'Brien  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25c80476e4SDavid E. O'Brien  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26c80476e4SDavid E. O'Brien  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27c80476e4SDavid E. O'Brien  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28c80476e4SDavid E. O'Brien  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29c80476e4SDavid E. O'Brien  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30c80476e4SDavid E. O'Brien  * SUCH DAMAGE.
31c80476e4SDavid E. O'Brien  */
32c80476e4SDavid E. O'Brien #ifndef _h_sh_proc
33c80476e4SDavid E. O'Brien #define _h_sh_proc
34c80476e4SDavid E. O'Brien /*
35c80476e4SDavid E. O'Brien  * C shell - process structure declarations
36c80476e4SDavid E. O'Brien  */
37c80476e4SDavid E. O'Brien 
38c80476e4SDavid E. O'Brien /*
39c80476e4SDavid E. O'Brien  * Structure for each process the shell knows about:
40c80476e4SDavid E. O'Brien  *	allocated and filled by pcreate.
41c80476e4SDavid E. O'Brien  *	flushed by pflush; freeing always happens at top level
42c80476e4SDavid E. O'Brien  *	    so the interrupt level has less to worry about.
43c80476e4SDavid E. O'Brien  *	processes are related to "friends" when in a pipeline;
44c80476e4SDavid E. O'Brien  *	    p_friends links makes a circular list of such jobs
45c80476e4SDavid E. O'Brien  */
46c80476e4SDavid E. O'Brien struct process {
47c80476e4SDavid E. O'Brien     struct process *p_next;	/* next in global "proclist" */
48c80476e4SDavid E. O'Brien     struct process *p_friends;	/* next in job list (or self) */
49c80476e4SDavid E. O'Brien     struct directory *p_cwd;	/* cwd of the job (only in head) */
50c80476e4SDavid E. O'Brien     unsigned long p_flags;	/* various job status flags */
51c80476e4SDavid E. O'Brien     unsigned char p_reason;	/* reason for entering this state */
52c80476e4SDavid E. O'Brien     int     p_index;		/* shorthand job index */
539ccc37e3SMark Peek     pid_t   p_parentid;		/* parent pid */
54c80476e4SDavid E. O'Brien     pid_t   p_procid;
55c80476e4SDavid E. O'Brien     pid_t   p_jobid;		/* pid of job leader */
56c80476e4SDavid E. O'Brien     /* if a job is stopped/background p_jobid gives its pgrp */
57c80476e4SDavid E. O'Brien #ifdef BSDTIMES
58c80476e4SDavid E. O'Brien     struct timeval p_btime;	/* begin time */
59c80476e4SDavid E. O'Brien     struct timeval p_etime;	/* end time */
60c80476e4SDavid E. O'Brien     struct sysrusage p_rusage;
61c80476e4SDavid E. O'Brien #else				/* BSDTIMES */
62c80476e4SDavid E. O'Brien # ifdef _SEQUENT_
63c80476e4SDavid E. O'Brien     timeval_t p_btime;		/* begin time */
64c80476e4SDavid E. O'Brien     timeval_t p_etime;		/* end time */
65c80476e4SDavid E. O'Brien     struct process_stats p_rusage;
66c80476e4SDavid E. O'Brien # else				/* _SEQUENT_ */
67c80476e4SDavid E. O'Brien #  ifndef POSIX
68c80476e4SDavid E. O'Brien     time_t  p_btime;		/* begin time */
69c80476e4SDavid E. O'Brien     time_t  p_etime;		/* end time */
70c80476e4SDavid E. O'Brien     time_t  p_utime;		/* user time */
71c80476e4SDavid E. O'Brien     time_t  p_stime;		/* system time */
72c80476e4SDavid E. O'Brien #  else	/* POSIX */
73c80476e4SDavid E. O'Brien     clock_t p_btime;		/* begin time */
74c80476e4SDavid E. O'Brien     clock_t p_etime;		/* end time */
75c80476e4SDavid E. O'Brien     clock_t p_utime;		/* user time */
76c80476e4SDavid E. O'Brien     clock_t p_stime;		/* system time */
77c80476e4SDavid E. O'Brien #  endif /* POSIX */
78c80476e4SDavid E. O'Brien # endif /* _SEQUENT_ */
79c80476e4SDavid E. O'Brien #endif /* BSDTIMES */
80a15e6f9aSMark Peek     Char   *p_command;		/* command */
81c80476e4SDavid E. O'Brien };
82c80476e4SDavid E. O'Brien 
83c80476e4SDavid E. O'Brien /* flag values for p_flags */
84c80476e4SDavid E. O'Brien #define	PRUNNING	(1<<0)	/* running */
85c80476e4SDavid E. O'Brien #define	PSTOPPED	(1<<1)	/* stopped */
86c80476e4SDavid E. O'Brien #define	PNEXITED	(1<<2)	/* normally exited */
87c80476e4SDavid E. O'Brien #define	PAEXITED	(1<<3)	/* abnormally exited */
88c80476e4SDavid E. O'Brien #define	PSIGNALED	(1<<4)	/* terminated by a signal != SIGINT */
89c80476e4SDavid E. O'Brien 
90c80476e4SDavid E. O'Brien #define	PALLSTATES	(PRUNNING|PSTOPPED|PNEXITED|PAEXITED| \
91c80476e4SDavid E. O'Brien 			 PSIGNALED|PINTERRUPTED)
92c80476e4SDavid E. O'Brien #define	PNOTIFY		(1<<5)	/* notify async when done */
93c80476e4SDavid E. O'Brien #define	PTIME		(1<<6)	/* job times should be printed */
94c80476e4SDavid E. O'Brien #define	PAWAITED	(1<<7)	/* top level is waiting for it */
95c80476e4SDavid E. O'Brien #define	PFOREGND	(1<<8)	/* started in shells pgrp */
96c80476e4SDavid E. O'Brien #define	PDUMPED		(1<<9)	/* process dumped core */
97c80476e4SDavid E. O'Brien #define	PDIAG		(1<<10)	/* diagnostic output also piped out */
98c80476e4SDavid E. O'Brien #define	PPOU		(1<<11)	/* piped output */
99c80476e4SDavid E. O'Brien #define	PREPORTED	(1<<12)	/* status has been reported */
100c80476e4SDavid E. O'Brien #define	PINTERRUPTED	(1<<13)	/* job stopped via interrupt signal */
101c80476e4SDavid E. O'Brien #define	PPTIME		(1<<14)	/* time individual process */
102c80476e4SDavid E. O'Brien #define	PNEEDNOTE	(1<<15)	/* notify as soon as practical */
103c80476e4SDavid E. O'Brien #define PBACKQ		(1<<16)	/* Process is `` evaluation */
104c80476e4SDavid E. O'Brien #define PHUP		(1<<17)	/* Process is marked for SIGHUP on exit */
1059ccc37e3SMark Peek #define PBRACE		(1<<18)	/* Process is {} evaluation */
106c80476e4SDavid E. O'Brien 
107c80476e4SDavid E. O'Brien /* defines for arguments to pprint */
108*19d2e3deSDmitry Chagin #define	NUMBER		0x001
109*19d2e3deSDmitry Chagin #define	NAME		0x002
110*19d2e3deSDmitry Chagin #define	REASON		0x004
111*19d2e3deSDmitry Chagin #define	AMPERSAND	0x008
112*19d2e3deSDmitry Chagin #define	FANCY		0x010
113*19d2e3deSDmitry Chagin #define	SHELLDIR	0x020	/* print shell's dir if not the same */
114*19d2e3deSDmitry Chagin #define	JOBDIR		0x040	/* print job's dir if not the same */
115*19d2e3deSDmitry Chagin #define	AREASON		0x080
116*19d2e3deSDmitry Chagin #define	JOBLIST		0x100
117c80476e4SDavid E. O'Brien 
118c80476e4SDavid E. O'Brien EXTERN struct process proclist IZERO_STRUCT;/* list head of all processes */
119c80476e4SDavid E. O'Brien 
120c80476e4SDavid E. O'Brien EXTERN struct process *pholdjob IZERO;	/* one level stack of current jobs */
121c80476e4SDavid E. O'Brien 
122c80476e4SDavid E. O'Brien EXTERN struct process *pcurrjob IZERO;	/* current job */
123c80476e4SDavid E. O'Brien EXTERN struct process *pcurrent IZERO;	/* current job in table */
124c80476e4SDavid E. O'Brien EXTERN struct process *pprevious IZERO;	/* previous job in table */
125c80476e4SDavid E. O'Brien 
126c80476e4SDavid E. O'Brien EXTERN int   pmaxindex IZERO;		/* current maximum job index */
127c80476e4SDavid E. O'Brien 
128c80476e4SDavid E. O'Brien #endif /* _h_sh_proc */
129