sh.proc.h revision 195609
1195609Smp/* $Header: /p/tcsh/cvsroot/tcsh/sh.proc.h,v 3.13 2009/06/19 16:35:33 christos Exp $ */ 259243Sobrien/* 359243Sobrien * sh.proc.h: Process data structures and variables 459243Sobrien */ 559243Sobrien/*- 659243Sobrien * Copyright (c) 1980, 1991 The Regents of the University of California. 759243Sobrien * All rights reserved. 859243Sobrien * 959243Sobrien * Redistribution and use in source and binary forms, with or without 1059243Sobrien * modification, are permitted provided that the following conditions 1159243Sobrien * are met: 1259243Sobrien * 1. Redistributions of source code must retain the above copyright 1359243Sobrien * notice, this list of conditions and the following disclaimer. 1459243Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1559243Sobrien * notice, this list of conditions and the following disclaimer in the 1659243Sobrien * documentation and/or other materials provided with the distribution. 17100616Smp * 3. Neither the name of the University nor the names of its contributors 1859243Sobrien * may be used to endorse or promote products derived from this software 1959243Sobrien * without specific prior written permission. 2059243Sobrien * 2159243Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2259243Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2359243Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2459243Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2559243Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2659243Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2759243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2859243Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2959243Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3059243Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3159243Sobrien * SUCH DAMAGE. 3259243Sobrien */ 3359243Sobrien#ifndef _h_sh_proc 3459243Sobrien#define _h_sh_proc 3559243Sobrien/* 3659243Sobrien * C shell - process structure declarations 3759243Sobrien */ 3859243Sobrien 3959243Sobrien/* 4059243Sobrien * Structure for each process the shell knows about: 4159243Sobrien * allocated and filled by pcreate. 4259243Sobrien * flushed by pflush; freeing always happens at top level 4359243Sobrien * so the interrupt level has less to worry about. 4459243Sobrien * processes are related to "friends" when in a pipeline; 4559243Sobrien * p_friends links makes a circular list of such jobs 4659243Sobrien */ 4759243Sobrienstruct process { 4859243Sobrien struct process *p_next; /* next in global "proclist" */ 4959243Sobrien struct process *p_friends; /* next in job list (or self) */ 5059243Sobrien struct directory *p_cwd; /* cwd of the job (only in head) */ 5159243Sobrien unsigned long p_flags; /* various job status flags */ 5259243Sobrien unsigned char p_reason; /* reason for entering this state */ 5359243Sobrien int p_index; /* shorthand job index */ 5459243Sobrien pid_t p_procid; 5559243Sobrien pid_t p_jobid; /* pid of job leader */ 5659243Sobrien /* if a job is stopped/background p_jobid gives its pgrp */ 5759243Sobrien#ifdef BSDTIMES 5859243Sobrien struct timeval p_btime; /* begin time */ 5959243Sobrien struct timeval p_etime; /* end time */ 6059243Sobrien struct sysrusage p_rusage; 6159243Sobrien#else /* BSDTIMES */ 6259243Sobrien# ifdef _SEQUENT_ 6359243Sobrien timeval_t p_btime; /* begin time */ 6459243Sobrien timeval_t p_etime; /* end time */ 6559243Sobrien struct process_stats p_rusage; 6659243Sobrien# else /* _SEQUENT_ */ 6759243Sobrien# ifndef POSIX 6859243Sobrien time_t p_btime; /* begin time */ 6959243Sobrien time_t p_etime; /* end time */ 7059243Sobrien time_t p_utime; /* user time */ 7159243Sobrien time_t p_stime; /* system time */ 7259243Sobrien# else /* POSIX */ 7359243Sobrien clock_t p_btime; /* begin time */ 7459243Sobrien clock_t p_etime; /* end time */ 7559243Sobrien clock_t p_utime; /* user time */ 7659243Sobrien clock_t p_stime; /* system time */ 7759243Sobrien# endif /* POSIX */ 7859243Sobrien# endif /* _SEQUENT_ */ 7959243Sobrien#endif /* BSDTIMES */ 80195609Smp Char *p_command; /* command */ 8159243Sobrien}; 8259243Sobrien 8359243Sobrien/* flag values for p_flags */ 8459243Sobrien#define PRUNNING (1<<0) /* running */ 8559243Sobrien#define PSTOPPED (1<<1) /* stopped */ 8659243Sobrien#define PNEXITED (1<<2) /* normally exited */ 8759243Sobrien#define PAEXITED (1<<3) /* abnormally exited */ 8859243Sobrien#define PSIGNALED (1<<4) /* terminated by a signal != SIGINT */ 8959243Sobrien 9059243Sobrien#define PALLSTATES (PRUNNING|PSTOPPED|PNEXITED|PAEXITED| \ 9159243Sobrien PSIGNALED|PINTERRUPTED) 9259243Sobrien#define PNOTIFY (1<<5) /* notify async when done */ 9359243Sobrien#define PTIME (1<<6) /* job times should be printed */ 9459243Sobrien#define PAWAITED (1<<7) /* top level is waiting for it */ 9559243Sobrien#define PFOREGND (1<<8) /* started in shells pgrp */ 9659243Sobrien#define PDUMPED (1<<9) /* process dumped core */ 9759243Sobrien#define PDIAG (1<<10) /* diagnostic output also piped out */ 9859243Sobrien#define PPOU (1<<11) /* piped output */ 9959243Sobrien#define PREPORTED (1<<12) /* status has been reported */ 10059243Sobrien#define PINTERRUPTED (1<<13) /* job stopped via interrupt signal */ 10159243Sobrien#define PPTIME (1<<14) /* time individual process */ 10259243Sobrien#define PNEEDNOTE (1<<15) /* notify as soon as practical */ 10359243Sobrien#define PBACKQ (1<<16) /* Process is `` evaluation */ 10459243Sobrien#define PHUP (1<<17) /* Process is marked for SIGHUP on exit */ 10559243Sobrien 10659243Sobrien/* defines for arguments to pprint */ 10759243Sobrien#define NUMBER 01 10859243Sobrien#define NAME 02 10959243Sobrien#define REASON 04 11059243Sobrien#define AMPERSAND 010 11159243Sobrien#define FANCY 020 11259243Sobrien#define SHELLDIR 040 /* print shell's dir if not the same */ 11359243Sobrien#define JOBDIR 0100 /* print job's dir if not the same */ 11459243Sobrien#define AREASON 0200 11559243Sobrien 11659243SobrienEXTERN struct process proclist IZERO_STRUCT;/* list head of all processes */ 11759243Sobrien 11859243SobrienEXTERN struct process *pholdjob IZERO; /* one level stack of current jobs */ 11959243Sobrien 12059243SobrienEXTERN struct process *pcurrjob IZERO; /* current job */ 12159243SobrienEXTERN struct process *pcurrent IZERO; /* current job in table */ 12259243SobrienEXTERN struct process *pprevious IZERO; /* previous job in table */ 12359243Sobrien 12459243SobrienEXTERN int pmaxindex IZERO; /* current maximum job index */ 12559243Sobrien 12659243Sobrien#endif /* _h_sh_proc */ 127