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