Commit | Line | Data |
---|---|---|
ecc449eb | 1 | /*- |
ed72f0a0 KB |
2 | * Copyright (c) 1980, 1991, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
ecc449eb KB |
4 | * |
5 | * %sccs.include.redist.c% | |
b79f4fa9 | 6 | * |
ed72f0a0 | 7 | * @(#)proc.h 8.1 (Berkeley) %G% |
0b076053 BJ |
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 | */ | |
6e37afca KB |
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 */ | |
135042ac | 24 | int p_index; /* shorthand job index */ |
6e37afca KB |
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 */ | |
0b076053 BJ |
32 | }; |
33 | ||
34 | /* flag values for p_flags */ | |
6e37afca KB |
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 */ | |
0b076053 BJ |
40 | |
41 | #define PALLSTATES (PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED) | |
6e37afca KB |
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 */ | |
454c2aa3 | 47 | #define PERR (1<<10) /* diagnostic output also piped out */ |
6e37afca KB |
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 */ | |
0b076053 | 53 | |
0b076053 BJ |
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 | |
6e37afca KB |
62 | #define SHELLDIR 040 /* print shell's dir if not the same */ |
63 | #define JOBDIR 0100 /* print job's dir if not the same */ | |
0b076053 BJ |
64 | #define AREASON 0200 |
65 | ||
6e37afca KB |
66 | struct process proclist; /* list head of all processes */ |
67 | bool pnoprocesses; /* pchild found nothing to wait for */ | |
0b076053 | 68 | |
6e37afca | 69 | struct process *pholdjob; /* one level stack of current jobs */ |
0b076053 | 70 | |
6e37afca KB |
71 | struct process *pcurrjob; /* current job */ |
72 | struct process *pcurrent; /* current job in table */ | |
73 | struct process *pprevious; /* previous job in table */ | |
0b076053 | 74 | |
135042ac | 75 | int pmaxindex; /* current maximum job index */ |