home *** CD-ROM | disk | FTP | other *** search
- /* History:
- 5/1/91 DJB baseline public domain
- */
-
- /*
-
- char *printpstat(p) struct proc *p; returns a string representing
- various basic information about p's status (with p in user memory).
- Not well defined.
-
- */
-
- #include <stdio.h>
- #include <strings.h>
- #include "printpstat.h"
- #include "structproc.h"
- #include "confhavepflag.h"
-
- static char result[300];
- /* XXX: 300 is guaranteed safe for the current code, but if you add */
- /* more printing flags, you may have to bring the number up. */
-
- char *printpstat(p)
- struct proc *p;
- {
- int pstat;
- int pflag;
- char *t;
-
- pstat = p->p_stat;
- #ifndef HAVE_PFLAG
- pflag = p->p_select | p->p_sched | p->p_vm; /*XXX: annoying*/
- #else
- pflag = p->p_flag;
- #endif
-
- switch(pstat)
- {
- #ifdef SSLEEP
- case SSLEEP: strcpy(result,"S "); break;
- #endif
- #ifdef SWAIT
- case SWAIT: strcpy(result,"D "); break;
- #endif
- #ifdef SRUN
- case SRUN: strcpy(result,"R "); break;
- #endif
- #ifdef SIDL
- case SIDL: strcpy(result,"X "); break;
- #endif
- #ifdef SZOMB
- case SZOMB: strcpy(result,"Z "); break;
- #endif
- #ifdef SSTOP
- case SSTOP: strcpy(result,"T "); break;
- #endif
- default: strcpy(result,"? ");
- }
- t = result + 2;
-
- #define PFLAG(S,X) if (pflag & S) { strcpy(t,X); t += strlen(t); pflag &= ~S; }
-
- #ifdef SLOAD
- PFLAG(SLOAD,"load ")
- #endif
- #ifdef SSYS
- PFLAG(SSYS,"sys ")
- #endif
- #ifdef SLOCK
- PFLAG(SLOCK,"lock ")
- #endif
- #ifdef SSWAP
- PFLAG(SSWAP,"swap ")
- #endif
- #ifdef SOMASK
- PFLAG(SOMASK,"omask ")
- #endif
- #ifdef SWEXIT
- PFLAG(SWEXIT,"wexit ")
- #endif
- #ifdef SWTED
- PFLAG(SWTED,"wted ")
- #endif
- #ifdef SULOCK
- PFLAG(SULOCK,"ulock ")
- #endif
- #ifdef STRC
- PFLAG(STRC,"traced ")
- #endif
- #ifdef SPAGI
- PFLAG(SPAGI,"ipage ")
- #endif
- #ifdef SSEL
- PFLAG(SSEL,"sel! ")
- #endif
- #ifdef SPTECHG
- PFLAG(SPTECHG,"ptechg ")
- #endif
- #ifdef SEXECDN
- PFLAG(SEXECDN,"execdn ")
- #endif
- #ifdef SVFORK
- PFLAG(SVFORK,"vfork ")
- #endif
- #ifdef SVFDONE
- PFLAG(SVFDONE,"vfdone ")
- #endif
- #ifdef SNOVM
- PFLAG(SNOVM,"novm ")
- #endif
- if (pflag)
- {
- sprintf(t,"flag %x ",pflag);
- }
- return result;
- }
-