![]() |
![]() |
00001 #ifndef CLASSLIB_PROCESS_INFO_H 00002 # define CLASSLIB_PROCESS_INFO_H 00003 00004 //<<<<<< INCLUDES >>>>>> 00005 00006 # include "classlib/sysapi/system.h" 00007 # include <sys/types.h> 00008 # include <string> 00009 00010 namespace lat { 00011 //<<<<<< PUBLIC DEFINES >>>>>> 00012 //<<<<<< PUBLIC CONSTANTS >>>>>> 00013 //<<<<<< PUBLIC TYPES >>>>>> 00014 //<<<<<< PUBLIC VARIABLES >>>>>> 00015 //<<<<<< PUBLIC FUNCTIONS >>>>>> 00016 //<<<<<< CLASS DECLARATIONS >>>>>> 00017 00019 class ProcessInfo 00020 { 00021 public: 00022 static pid_t pid (void); 00023 static pid_t ppid (void); 00024 00025 static int argc (void); 00026 static char ** argv (void); 00027 00028 static std::string fullProgramName (void); 00029 static std::string shortProgramName (void); 00030 00031 // FIXME: get vmstats 00032 // - linux: /proc/self/status 00033 // - solaris: /proc/self/status (read pstatus.pr_brkbase, 00034 // .pr_brksize, .pr_stkbase, .pr_stksize) 00035 // or maybe psinfo (psinfo.pr_size, .pr_rssize) 00036 // - unix: ps -o vsz= -o rss= -p <PID> 00037 00038 // FIXME: get vmmap 00039 // - linux: /proc/self/maps 00040 // - solaris: /proc/self/map (prmap.pr_vaddr, .pr_size, 00041 // .pr_mapname => /proc/self/object/$N) 00042 // - hpux: pstat_getprocvm() 00043 00044 // FIXME: resource usage 00045 // - linux: read /proc/self/stat (or status) 00046 // - solaris: read /proc/self/usage 00047 00048 // FIXME: system information 00049 // - linux: /proc/cpuinfo etc. 00050 // - hpux: pstat_getstatic(), pstat_getdynamic(), pstat_getvminfo() 00051 00052 // FIXME: open files 00053 // - linux, solaris: /proc/self/fd/N 00054 // - hpux: pstat_getfile() 00055 00056 // FIXME: for hp-ux, look pstat man page and Mike Stroyan's mails. 00057 00058 // FIXME: for IRIX, look at https://reality.sgi.com/davea/software.html 00059 // and https://reality.sgi.com/performer/perf-95-09/0153.html 00060 // and IRIX Device Driver Programmer's Guide at 00061 // https://dmawww.epfl.ch/ebt-bin/nph-dweb/dynaweb/SGI_Developer/ 00062 // DevDriver_PG/@Generic__BookTextView/2687 00063 // and https://dmawww.epfl.ch:80/ebt-bin/nph-dweb/dynaweb/SGI_Developer/ 00064 // T_IRIX_Prog/@Generic__BookView?DwebQuery=syssgi 00065 // Virtual and resident sizes of a process: syssgi(SGI_PROCSZ, 00066 // pid, &uiSZ, &uiRSS); 00067 // https://www.mcsr.olemiss.edu/cgi-bin/man-cgi?syssgi+2 00068 00069 // FIXME: on linux, use /proc/self/statm to get process memory stats 00070 // FIXME: on solaris, use /proc/self/status, usage, map (or rmap?) 00071 00072 // FIXME: get resource limits with getrlimit 00073 00074 // FIXME: time usage: times(2) 00075 }; 00076 00077 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> 00078 00079 } // namespace lat 00080 #endif // CLASSLIB_PROCESS_INFO_H