xref: /illumos-gate/usr/src/cmd/csh/sh.proc.h (revision 1a2d662a91cee3bf82f41cd47c7ae6f3825d9db2)
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 /*
16  * C shell - process structure declarations
17  */
18 
19 /*
20  * Structure for each process the shell knows about:
21  *	allocated and filled by pcreate.
22  *	flushed by pflush; freeing always happens at top level
23  *	    so the interrupt level has less to worry about.
24  *	processes are related to "friends" when in a pipeline;
25  *	    p_friends links makes a circular list of such jobs
26  */
27 struct process	{
28 	struct	process *p_next;	/* next in global "proclist" */
29 	struct	process	*p_friends;	/* next in job list (or self) */
30 	struct	directory *p_cwd;	/* cwd of the job (only in head) */
31 	short	unsigned p_flags;	/* various job status flags */
32  tchar p_reason;		/* reason for entering this state */
33  tchar p_index;		/* shorthand job index */
34 	int	p_pid;
35 	int	p_jobid;		/* pid of job leader */
36 	/* if a job is stopped/background p_jobid gives its pgrp */
37 	struct	timeval p_btime;	/* begin time */
38 	struct	timeval p_etime;	/* end time */
39 	struct	rusage p_rusage;
40  tchar *p_command;		/* first PMAXLEN chars of command */
41 };
42 
43 /* added for status */
44 #define	ABN_TERM	0200
45 
46 /* flag values for p_flags */
47 #define	PRUNNING	(1<<0)		/* running */
48 #define	PSTOPPED	(1<<1)		/* stopped */
49 #define	PNEXITED	(1<<2)		/* normally exited */
50 #define	PAEXITED	(1<<3)		/* abnormally exited */
51 #define	PSIGNALED	(1<<4)		/* terminated by a signal != SIGINT */
52 
53 #define	PALLSTATES	(PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED)
54 #define	PNOTIFY		(1<<5)		/* notify async when done */
55 #define	PTIME		(1<<6)		/* job times should be printed */
56 #define	PAWAITED	(1<<7)		/* top level is waiting for it */
57 #define	PFOREGND	(1<<8)		/* started in shells pgrp */
58 #define	PDUMPED		(1<<9)		/* process dumped core */
59 #define	PDIAG		(1<<10)		/* diagnostic output also piped out */
60 #define	PPOU		(1<<11)		/* piped output */
61 #define	PREPORTED	(1<<12)		/* status has been reported */
62 #define	PINTERRUPTED	(1<<13)		/* job stopped via interrupt signal */
63 #define	PPTIME		(1<<14)		/* time individual process */
64 #define	PNEEDNOTE	(1<<15)		/* notify as soon as practical */
65 
66 #define	PNULL		(struct process *)0
67 #define	PMAXLEN		80
68 
69 /* defines for arguments to pprint */
70 #define	NUMBER		01
71 #define	NAME		02
72 #define	REASON		04
73 #define	AMPERSAND	010
74 #define	FANCY		020
75 #define	SHELLDIR	040		/* print shell's dir if not the same */
76 #define	JOBDIR		0100		/* print job's dir if not the same */
77 #define	AREASON		0200
78 
79 extern struct	process *pcurrjob;	/* current job */
80