1 #include <stdlib.h> 2 #include <stdio.h> 3 #include <fcntl.h> 4 #include <dirent.h> 5 #include <string.h> 6 #include <sys/resource.h> 7 #include <unistd.h> 8 #include <sys/proc.h> /* needed for process state constants */ 9 #include <sys/statvfs.h> 10 #include <sys/types.h> 11 #include <sys/sysmp.h> 12 13 #if defined(PROC_FS) 14 #include <procfs.h> 15 #else 16 #include <sys/procfs.h> 17 #endif 18 19 #ifdef i386 20 #undef SP 21 #define SP sp 22 #endif 23 24 /****************************************/ 25 /* Process state strings that we return */ 26 /****************************************/ 27 #define SLEEP "sleep" 28 #define WAIT "wait" 29 #define RUN "run" 30 #define IDLE "idle" 31 #define ZOMBIE "defunct" 32 #define STOP "stop" 33 #define XBRK "xswapped" 34 35 /* Solaris is an all-or-nothing deal, all this stuff comes out of 36 one structure, so we don't need to dick around with the format much */ 37 static char Format[] = "iiiiiiiilllllllllslsssss"; 38 39 /* Mapping of field to type */ 40 static char* Fields[] = { 41 42 "uid", 43 "gid", 44 "pid", 45 "ppid", 46 "spid", 47 "pgrp", 48 "sess", 49 "cpuid", 50 51 "priority", 52 "ttynum", 53 "flags", 54 "time", 55 "ctime", 56 "qtime", 57 "size", 58 "rss", 59 "wchan", 60 61 "fname", 62 63 "start", 64 65 "pctcpu", 66 "state", 67 "pctmem", 68 "cmndline", 69 "clname" 70 }; 71 72 73 74 75 76 77 78 79 80