17c478bd9Sstevel@tonic-gate /* 26c02b4a4Smuffin * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 77c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate /* 107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley Software License Agreement 127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate /* 167c478bd9Sstevel@tonic-gate * C shell - process structure declarations 177c478bd9Sstevel@tonic-gate */ 187c478bd9Sstevel@tonic-gate 197c478bd9Sstevel@tonic-gate /* 207c478bd9Sstevel@tonic-gate * Structure for each process the shell knows about: 217c478bd9Sstevel@tonic-gate * allocated and filled by pcreate. 227c478bd9Sstevel@tonic-gate * flushed by pflush; freeing always happens at top level 237c478bd9Sstevel@tonic-gate * so the interrupt level has less to worry about. 247c478bd9Sstevel@tonic-gate * processes are related to "friends" when in a pipeline; 257c478bd9Sstevel@tonic-gate * p_friends links makes a circular list of such jobs 267c478bd9Sstevel@tonic-gate */ 277c478bd9Sstevel@tonic-gate struct process { 287c478bd9Sstevel@tonic-gate struct process *p_next; /* next in global "proclist" */ 297c478bd9Sstevel@tonic-gate struct process *p_friends; /* next in job list (or self) */ 307c478bd9Sstevel@tonic-gate struct directory *p_cwd; /* cwd of the job (only in head) */ 317c478bd9Sstevel@tonic-gate short unsigned p_flags; /* various job status flags */ 327c478bd9Sstevel@tonic-gate tchar p_reason; /* reason for entering this state */ 337c478bd9Sstevel@tonic-gate tchar p_index; /* shorthand job index */ 347c478bd9Sstevel@tonic-gate int p_pid; 357c478bd9Sstevel@tonic-gate int p_jobid; /* pid of job leader */ 367c478bd9Sstevel@tonic-gate /* if a job is stopped/background p_jobid gives its pgrp */ 377c478bd9Sstevel@tonic-gate struct timeval p_btime; /* begin time */ 387c478bd9Sstevel@tonic-gate struct timeval p_etime; /* end time */ 397c478bd9Sstevel@tonic-gate struct rusage p_rusage; 407c478bd9Sstevel@tonic-gate tchar *p_command; /* first PMAXLEN chars of command */ 417c478bd9Sstevel@tonic-gate }; 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* added for status */ 447c478bd9Sstevel@tonic-gate #define ABN_TERM 0200 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate /* flag values for p_flags */ 477c478bd9Sstevel@tonic-gate #define PRUNNING (1<<0) /* running */ 487c478bd9Sstevel@tonic-gate #define PSTOPPED (1<<1) /* stopped */ 497c478bd9Sstevel@tonic-gate #define PNEXITED (1<<2) /* normally exited */ 507c478bd9Sstevel@tonic-gate #define PAEXITED (1<<3) /* abnormally exited */ 517c478bd9Sstevel@tonic-gate #define PSIGNALED (1<<4) /* terminated by a signal != SIGINT */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define PALLSTATES (PRUNNING|PSTOPPED|PNEXITED|PAEXITED|PSIGNALED|PINTERRUPTED) 547c478bd9Sstevel@tonic-gate #define PNOTIFY (1<<5) /* notify async when done */ 557c478bd9Sstevel@tonic-gate #define PTIME (1<<6) /* job times should be printed */ 567c478bd9Sstevel@tonic-gate #define PAWAITED (1<<7) /* top level is waiting for it */ 577c478bd9Sstevel@tonic-gate #define PFOREGND (1<<8) /* started in shells pgrp */ 587c478bd9Sstevel@tonic-gate #define PDUMPED (1<<9) /* process dumped core */ 597c478bd9Sstevel@tonic-gate #define PDIAG (1<<10) /* diagnostic output also piped out */ 607c478bd9Sstevel@tonic-gate #define PPOU (1<<11) /* piped output */ 617c478bd9Sstevel@tonic-gate #define PREPORTED (1<<12) /* status has been reported */ 627c478bd9Sstevel@tonic-gate #define PINTERRUPTED (1<<13) /* job stopped via interrupt signal */ 637c478bd9Sstevel@tonic-gate #define PPTIME (1<<14) /* time individual process */ 647c478bd9Sstevel@tonic-gate #define PNEEDNOTE (1<<15) /* notify as soon as practical */ 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #define PNULL (struct process *)0 677c478bd9Sstevel@tonic-gate #define PMAXLEN 80 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate /* defines for arguments to pprint */ 707c478bd9Sstevel@tonic-gate #define NUMBER 01 717c478bd9Sstevel@tonic-gate #define NAME 02 727c478bd9Sstevel@tonic-gate #define REASON 04 737c478bd9Sstevel@tonic-gate #define AMPERSAND 010 747c478bd9Sstevel@tonic-gate #define FANCY 020 757c478bd9Sstevel@tonic-gate #define SHELLDIR 040 /* print shell's dir if not the same */ 767c478bd9Sstevel@tonic-gate #define JOBDIR 0100 /* print job's dir if not the same */ 777c478bd9Sstevel@tonic-gate #define AREASON 0200 787c478bd9Sstevel@tonic-gate 79*258f91c6SToomas Soome extern struct process *pcurrjob; /* current job */ 80