| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# ProcessDescriptor.cpp File Reference

`#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"`

Include dependency graph for ProcessDescriptor.cpp:

Go to the source code of this file.

## Namespaces
namespace | System
## Classes
struct | linux_proc
## Defines
#define | GAUDIKERNEL_PROCSTAT_CPP
#define | WINVER 0
## Enumerations
enum | System::ProcessInfoCommand { System::ProcessBasicInformation, System::ProcessQuotaLimits, System::ProcessIoCounters, System::ProcessVmCounters, System::ProcessTimes, System::ProcessBasePriority, System::ProcessRaisePriority, System::ProcessDebugPort, System::ProcessExceptionPort, System::ProcessAccessToken, System::ProcessLdtInformation, System::ProcessLdtSize, System::ProcessDefaultHardErrorMode, System::ProcessIoPortHandlers, System::ProcessPooledUsageAndLimits, System::ProcessWorkingSetWatch, System::ProcessUserModeIOPL, System::ProcessEnableAlignmentFaultFixup, System::ProcessPriorityClass, System::ProcessWx86Information, System::ProcessHandleCount, System::ProcessAffinityMask, System::ProcessPriorityBoost, System::MaxProcessInfoClass, System::ProcessEllapsedTime }
## Functions
void | readProcStat (long pid, linux_proc &pinfo)
static long | processID (long pid)
System::ProcessDescriptor * | System::getProcess ()
| Retrieve Process structure.
## Variables
static const long | TICK_TO_100NSEC = 100000
static long | pg_size = sysconf(_SC_PAGESIZE)
static long | s_myPid = ::getpid()

## Define Documentation

#define GAUDIKERNEL_PROCSTAT_CPP

Definition at line 16 of file ProcessDescriptor.cpp.

#define WINVER 0

Definition at line 73 of file ProcessDescriptor.cpp.

## Function Documentation

static long processID | ( | long | pid | ) | `[inline, static]`

Definition at line 203 of file ProcessDescriptor.cpp.

    00203                                        {
    00204   long thePid = (pid>0) ? pid : s_myPid;
    00205   return thePid;
    00206 }

void readProcStat | ( | long | pid,
|  | linux_proc & | pinfo |
| ) |  |  |

Definition at line 137 of file ProcessDescriptor.cpp.

    00137                                                {
    00138
    00139   int cnt, fd;
    00140   char buf[512];
    00141
    00142   std::ostringstream ost;
    00143
    00144   ost << "/proc/" << pid << "/stat";
    00145   std::string fname = ost.str();
    00146   if((fd=open(fname.c_str(),O_RDONLY))<0)  {
    00147     std::cerr << "Failed to open " << ost.str() << std::endl;
    00148     return;
    00149   }
    00150
    00151   lseek(fd,0,SEEK_SET);
    00152   if((cnt=read(fd,buf,sizeof(buf)))<0)  {
    00153     std::cout << "LINUX Read of Proc file failed:" << std::endl;
    00154     return;
    00155   }
    00156
    00157   if(cnt>0)     {
    00158     buf[cnt]='\0';
    00159     sscanf(buf,
    00160            "%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",
    00161            &pinfo.pid, // %d
    00162            pinfo.comm, // %s
    00163            &pinfo.state, // %c
    00164            &pinfo.ppid, // %d
    00165            &pinfo.pgrp, // %d
    00166            &pinfo.session, // %d
    00167            &pinfo.tty, // %d
    00168            &pinfo.tpgid, // %d
    00169            &pinfo.flags, // %u
    00170            &pinfo.minflt, // %u
    00171            &pinfo.cminflt, // %u
    00172            &pinfo.majflt, // %u
    00173            &pinfo.cmajflt, // %u
    00174            &pinfo.utime, // %d
    00175            &pinfo.stime, // %d
    00176            &pinfo.cutime, // %d
    00177            &pinfo.cstime, // %d
    00178            &pinfo.counter, // %d
    00179            &pinfo.priority, // %d
    00180            &pinfo.timeout, // %u
    00181            &pinfo.itrealvalue, // %u
    00182            &pinfo.starttime, // %d
    00183            &pinfo.vsize, // %u
    00184            &pinfo.rss, // %u
    00185            &pinfo.rlim, // %u
    00186            &pinfo.startcode, // %l
    00187            &pinfo.endcode, // %l
    00188            &pinfo.startstack, // %u
    00189            &pinfo.kstkesp, // %u
    00190            &pinfo.kstkeip, // %u
    00191            &pinfo.signal, // %d
    00192            &pinfo.blocked, // %d
    00193            &pinfo.sigignore, // %d
    00194            &pinfo.sigcatch, // %d
    00195            &pinfo.wchan // %u
    00196            );
    00197   }
    00198   close(fd);
    00199 }

## Variable Documentation

long pg_size = sysconf(_SC_PAGESIZE)`[static]`

Definition at line 135 of file ProcessDescriptor.cpp.

long s_myPid = ::getpid()`[static]`

Definition at line 202 of file ProcessDescriptor.cpp.

const long TICK_TO_100NSEC = 100000`[static]`

Definition at line 18 of file ProcessDescriptor.cpp.