xref: /illumos-gate/usr/src/cmd/csh/sh.proc.h (revision 657a8c206b913d1ee578fd725f0b25eca5b77253)
1 /*
2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved. The Berkeley Software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 /*
18  * C shell - process structure declarations
19  */
20 
21 /*
22  * Structure for each process the shell knows about:
23  *	allocated and filled by pcreate.
24  *	flushed by pflush; freeing always happens at top level
25  *	    so the interrupt level has less to worry about.
26  *	processes are related to "friends" when in a pipeline;
27  *	    p_friends links makes a circular list of such jobs
28  */
29 struct process	{
30 	struct	process *p_next;	/* next in global "proclist" */
31 	struct	process	*p_friends;	/* next in job list (or self) */
32 	struct	directory *p_cwd;	/* cwd of the job (only in head) */
33 	short	unsigned p_flags;	/* various job status flags */
34  tchar p_reason;		/* reason for entering this state */
35  tchar p_index;		/* shorthand job index */
36 	int	p_pid;
37 	int	p_jobid;		/* pid of job leader */
38 	/* if a job is stopped/background p_jobid gives its pgrp */
39 	struct	timeval p_btime;	/* begin time */
40 	struct	timeval p_etime;	/* end time */
41 	struct	rusage p_rusage;
42  tchar *p_command;		/* first PMAXLEN chars of command */
43 };
44 
45 /* added for status */
46 #define	ABN_TERM	0200
47 
48 /* flag values for p_flags */
49 #define	PRUNNING	(1<<0)		/* running */
50 #define	PSTOPPED	(1<<1)		/* stopped */
51 #define	PNEXITED	(1<<2)		/* normally exited */
52 #define	PAEXITED	(1<<3)		/* abnormally exited */
53 #define	PSIGNALED	(1<<4)		/* terminated by a signal != SIGINT */
54 
55 #define	PALLSTATES	(PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED)
56 #define	PNOTIFY		(1<<5)		/* notify async when done */
57 #define	PTIME		(1<<6)		/* job times should be printed */
58 #define	PAWAITED	(1<<7)		/* top level is waiting for it */
59 #define	PFOREGND	(1<<8)		/* started in shells pgrp */
60 #define	PDUMPED		(1<<9)		/* process dumped core */
61 #define	PDIAG		(1<<10)		/* diagnostic output also piped out */
62 #define	PPOU		(1<<11)		/* piped output */
63 #define	PREPORTED	(1<<12)		/* status has been reported */
64 #define	PINTERRUPTED	(1<<13)		/* job stopped via interrupt signal */
65 #define	PPTIME		(1<<14)		/* time individual process */
66 #define	PNEEDNOTE	(1<<15)		/* notify as soon as practical */
67 
68 #define	PNULL		(struct process *)0
69 #define	PMAXLEN		80
70 
71 /* defines for arguments to pprint */
72 #define	NUMBER		01
73 #define	NAME		02
74 #define	REASON		04
75 #define	AMPERSAND	010
76 #define	FANCY		020
77 #define	SHELLDIR	040		/* print shell's dir if not the same */
78 #define	JOBDIR		0100		/* print job's dir if not the same */
79 #define	AREASON		0200
80 
81 struct	process	proclist;		/* list head of all processes */
82 bool	pnoprocesses;			/* pchild found nothing to wait for */
83 
84 struct	process *pholdjob;		/* one level stack of current jobs */
85 
86 struct	process *pcurrjob;		/* current job */
87 struct	process	*pcurrent;		/* current job in table */
88 struct	process *pprevious;		/* previous job in table */
89 
90 short	pmaxindex;			/* current maximum job index */
91