|
Gaudi Framework, version v22r1 |
| Home | Generated: Mon Feb 28 2011 |
#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 16 of file ProcessDescriptor.cpp.
| #define s_myPid (::getpid()) |
Definition at line 204 of file ProcessDescriptor.cpp.
| #define WINVER 0 |
Definition at line 73 of file ProcessDescriptor.cpp.
Definition at line 205 of file ProcessDescriptor.cpp.
{
long thePid = (pid>0) ? pid : s_myPid;
return thePid;
}
| void readProcStat | ( | long | pid, |
| linux_proc & | pinfo | ||
| ) |
Definition at line 137 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;
return;
}
if(cnt>0) {
buf[cnt]='\0';
sscanf(buf,
"%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %lu %lu %u %u %u %d %d %d %d %u",
&pinfo.pid, // %d
pinfo.comm, // %s
&pinfo.state, // %c
&pinfo.ppid, // %d
&pinfo.pgrp, // %d
&pinfo.session, // %d
&pinfo.tty, // %d
&pinfo.tpgid, // %d
&pinfo.flags, // %u
&pinfo.minflt, // %u
&pinfo.cminflt, // %u
&pinfo.majflt, // %u
&pinfo.cmajflt, // %u
&pinfo.utime, // %d
&pinfo.stime, // %d
&pinfo.cutime, // %d
&pinfo.cstime, // %d
&pinfo.counter, // %d
&pinfo.priority, // %d
&pinfo.timeout, // %u
&pinfo.itrealvalue, // %u
&pinfo.starttime, // %d
&pinfo.vsize, // %u
&pinfo.rss, // %u
&pinfo.rlim, // %u
&pinfo.startcode, // %l
&pinfo.endcode, // %l
&pinfo.startstack, // %u
&pinfo.kstkesp, // %u
&pinfo.kstkeip, // %u
&pinfo.signal, // %d
&pinfo.blocked, // %d
&pinfo.sigignore, // %d
&pinfo.sigcatch, // %d
&pinfo.wchan // %u
);
}
close(fd);
}
Definition at line 135 of file ProcessDescriptor.cpp.
const long TICK_TO_100NSEC = 100000 [static] |
Definition at line 18 of file ProcessDescriptor.cpp.