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