xref: /original-bsd/bin/csh/proc.h (revision 5000927f)
1 /*-
2  * Copyright (c) 1980, 1991, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)proc.h	8.1 (Berkeley) 05/31/93
8  */
9 
10 /*
11  * Structure for each process the shell knows about:
12  *	allocated and filled by pcreate.
13  *	flushed by pflush; freeing always happens at top level
14  *	    so the interrupt level has less to worry about.
15  *	processes are related to "friends" when in a pipeline;
16  *	    p_friends links makes a circular list of such jobs
17  */
18 struct process {
19     struct process *p_next;	/* next in global "proclist" */
20     struct process *p_friends;	/* next in job list (or self) */
21     struct directory *p_cwd;	/* cwd of the job (only in head) */
22     short unsigned p_flags;	/* various job status flags */
23     char    p_reason;		/* reason for entering this state */
24     int     p_index;		/* shorthand job index */
25     int     p_pid;
26     int     p_jobid;		/* pid of job leader */
27     /* if a job is stopped/background p_jobid gives its pgrp */
28     struct timeval p_btime;	/* begin time */
29     struct timeval p_etime;	/* end time */
30     struct rusage p_rusage;
31     Char   *p_command;		/* first PMAXLEN chars of command */
32 };
33 
34 /* flag values for p_flags */
35 #define	PRUNNING	(1<<0)	/* running */
36 #define	PSTOPPED	(1<<1)	/* stopped */
37 #define	PNEXITED	(1<<2)	/* normally exited */
38 #define	PAEXITED	(1<<3)	/* abnormally exited */
39 #define	PSIGNALED	(1<<4)	/* terminated by a signal != SIGINT */
40 
41 #define	PALLSTATES	(PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED)
42 #define	PNOTIFY		(1<<5)	/* notify async when done */
43 #define	PTIME		(1<<6)	/* job times should be printed */
44 #define	PAWAITED	(1<<7)	/* top level is waiting for it */
45 #define	PFOREGND	(1<<8)	/* started in shells pgrp */
46 #define	PDUMPED		(1<<9)	/* process dumped core */
47 #define	PERR		(1<<10)	/* diagnostic output also piped out */
48 #define	PPOU		(1<<11)	/* piped output */
49 #define	PREPORTED	(1<<12)	/* status has been reported */
50 #define	PINTERRUPTED	(1<<13)	/* job stopped via interrupt signal */
51 #define	PPTIME		(1<<14)	/* time individual process */
52 #define	PNEEDNOTE	(1<<15)	/* notify as soon as practical */
53 
54 #define	PMAXLEN		80
55 
56 /* defines for arguments to pprint */
57 #define	NUMBER		01
58 #define	NAME		02
59 #define	REASON		04
60 #define	AMPERSAND	010
61 #define	FANCY		020
62 #define	SHELLDIR	040	/* print shell's dir if not the same */
63 #define	JOBDIR		0100	/* print job's dir if not the same */
64 #define	AREASON		0200
65 
66 struct process proclist;	/* list head of all processes */
67 bool    pnoprocesses;		/* pchild found nothing to wait for */
68 
69 struct process *pholdjob;	/* one level stack of current jobs */
70 
71 struct process *pcurrjob;	/* current job */
72 struct process *pcurrent;	/* current job in table */
73 struct process *pprevious;	/* previous job in table */
74 
75 int    pmaxindex;		/* current maximum job index */
76