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