|
Gaudi Framework, version v23r2 |
| Home | Generated: Thu Jun 28 2012 |
#include <errno.h>#include <string>#include "unistd.h"#include "libgen.h"#include <cstdio>#include <sstream>#include <iostream>#include <fcntl.h>#include "sys/times.h"#include <sys/types.h>#include <sys/signal.h>#include <sys/syscall.h>#include <sys/procfs.h>#include <sys/time.h>#include <sys/resource.h>#include "ProcessDescriptor.h"#include "GaudiKernel/ModuleInfo.h"#include "GaudiKernel/System.h"
Go to the source code of this file.
| #define GAUDIKERNEL_PROCSTAT_CPP |
Definition at line 15 of file ProcessDescriptor.cpp.
| #define s_myPid (::getpid()) |
Definition at line 373 of file ProcessDescriptor.cpp.
| #define WINVER 0 |
Definition at line 72 of file ProcessDescriptor.cpp.
| static long processID | ( | long | pid ) | [inline, static] |
Definition at line 374 of file ProcessDescriptor.cpp.
{
long thePid = (pid>0) ? pid : s_myPid;
return thePid;
}
| void readProcStat | ( | long | pid, |
| linux_proc & | pinfo | ||
| ) |
Definition at line 303 of file ProcessDescriptor.cpp.
{
int cnt, fd;
char buf[512];
std::ostringstream ost;
ost << "/proc/" << pid << "/stat";
std::string fname = ost.str();
if((fd=open(fname.c_str(),O_RDONLY))<0) {
std::cerr << "Failed to open " << ost.str() << std::endl;
return;
}
lseek(fd,0,SEEK_SET);
if((cnt=read(fd,buf,sizeof(buf)))<0) {
std::cout << "LINUX Read of Proc file failed:" << std::endl;
close(fd);
return;
}
// Format
if(cnt>0) {
buf[cnt]='\0';
sscanf(buf,
//1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 20 1 2 3 4 5 6 7 8 9 30 1 2 3 4 5
"%d %s %c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %llu %lu %ld %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
&pinfo.pid,
pinfo.comm,
&pinfo.state,
&pinfo.ppid,
&pinfo.pgrp,
&pinfo.session,
&pinfo.tty,
&pinfo.tpgid,
&pinfo.flags,
&pinfo.minflt,
&pinfo.cminflt,
&pinfo.majflt,
&pinfo.cmajflt,
&pinfo.utime,
&pinfo.stime,
&pinfo.cutime,
&pinfo.cstime,
&pinfo.priority,
&pinfo.nice,
&pinfo.num_threads,
&pinfo.itrealvalue,
&pinfo.starttime,
&pinfo.vsize,
&pinfo.rss,
&pinfo.rlim,
&pinfo.startcode,
&pinfo.endcode,
&pinfo.startstack,
&pinfo.kstkesp,
&pinfo.kstkeip,
&pinfo.signal,
&pinfo.blocked,
&pinfo.sigignore,
&pinfo.sigcatch,
&pinfo.wchan
);
}
close(fd);
}
long pg_size = sysconf(_SC_PAGESIZE) [static] |
Definition at line 301 of file ProcessDescriptor.cpp.
const long TICK_TO_100NSEC = 100000 [static] |
Definition at line 17 of file ProcessDescriptor.cpp.