147823Sbostic /*- 2*60765Sbostic * Copyright (c) 1980, 1991, 1993 3*60765Sbostic * The Regents of the University of California. All rights reserved. 421947Sdist * 547823Sbostic * %sccs.include.redist.c% 647823Sbostic * 7*60765Sbostic * @(#)proc.h 8.1 (Berkeley) 05/31/93 821947Sdist */ 91303Sbill 101303Sbill /* 111303Sbill * Structure for each process the shell knows about: 121303Sbill * allocated and filled by pcreate. 131303Sbill * flushed by pflush; freeing always happens at top level 141303Sbill * so the interrupt level has less to worry about. 151303Sbill * processes are related to "friends" when in a pipeline; 161303Sbill * p_friends links makes a circular list of such jobs 171303Sbill */ 1849992Sbostic struct process { 1949992Sbostic struct process *p_next; /* next in global "proclist" */ 2049992Sbostic struct process *p_friends; /* next in job list (or self) */ 2149992Sbostic struct directory *p_cwd; /* cwd of the job (only in head) */ 2249992Sbostic short unsigned p_flags; /* various job status flags */ 2349992Sbostic char p_reason; /* reason for entering this state */ 2450124Schristos int p_index; /* shorthand job index */ 2549992Sbostic int p_pid; 2649992Sbostic int p_jobid; /* pid of job leader */ 2749992Sbostic /* if a job is stopped/background p_jobid gives its pgrp */ 2849992Sbostic struct timeval p_btime; /* begin time */ 2949992Sbostic struct timeval p_etime; /* end time */ 3049992Sbostic struct rusage p_rusage; 3149992Sbostic Char *p_command; /* first PMAXLEN chars of command */ 321303Sbill }; 331303Sbill 341303Sbill /* flag values for p_flags */ 3549992Sbostic #define PRUNNING (1<<0) /* running */ 3649992Sbostic #define PSTOPPED (1<<1) /* stopped */ 3749992Sbostic #define PNEXITED (1<<2) /* normally exited */ 3849992Sbostic #define PAEXITED (1<<3) /* abnormally exited */ 3949992Sbostic #define PSIGNALED (1<<4) /* terminated by a signal != SIGINT */ 401303Sbill 411303Sbill #define PALLSTATES (PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED) 4249992Sbostic #define PNOTIFY (1<<5) /* notify async when done */ 4349992Sbostic #define PTIME (1<<6) /* job times should be printed */ 4449992Sbostic #define PAWAITED (1<<7) /* top level is waiting for it */ 4549992Sbostic #define PFOREGND (1<<8) /* started in shells pgrp */ 4649992Sbostic #define PDUMPED (1<<9) /* process dumped core */ 4750439Schristos #define PERR (1<<10) /* diagnostic output also piped out */ 4849992Sbostic #define PPOU (1<<11) /* piped output */ 4949992Sbostic #define PREPORTED (1<<12) /* status has been reported */ 5049992Sbostic #define PINTERRUPTED (1<<13) /* job stopped via interrupt signal */ 5149992Sbostic #define PPTIME (1<<14) /* time individual process */ 5249992Sbostic #define PNEEDNOTE (1<<15) /* notify as soon as practical */ 531303Sbill 541303Sbill #define PMAXLEN 80 551303Sbill 561303Sbill /* defines for arguments to pprint */ 571303Sbill #define NUMBER 01 581303Sbill #define NAME 02 591303Sbill #define REASON 04 601303Sbill #define AMPERSAND 010 611303Sbill #define FANCY 020 6249992Sbostic #define SHELLDIR 040 /* print shell's dir if not the same */ 6349992Sbostic #define JOBDIR 0100 /* print job's dir if not the same */ 641303Sbill #define AREASON 0200 651303Sbill 6649992Sbostic struct process proclist; /* list head of all processes */ 6749992Sbostic bool pnoprocesses; /* pchild found nothing to wait for */ 681303Sbill 6949992Sbostic struct process *pholdjob; /* one level stack of current jobs */ 701303Sbill 7149992Sbostic struct process *pcurrjob; /* current job */ 7249992Sbostic struct process *pcurrent; /* current job in table */ 7349992Sbostic struct process *pprevious; /* previous job in table */ 741303Sbill 7550124Schristos int pmaxindex; /* current maximum job index */ 76