ATLAS Offline Software
Functions
read_athena_statm.cxx File Reference
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "CxxUtils/read_athena_statm.h"
Include dependency graph for read_athena_statm.cxx:

Go to the source code of this file.

Functions

struct athena_statm read_athena_statm ()
 

Function Documentation

◆ read_athena_statm()

struct athena_statm read_athena_statm ( )

Definition at line 1 of file read_athena_statm.cxx.

16 {
17  struct athena_statm res = {0, 0};
18 #ifndef __APPLE__
19 
20  const char *filename = "/proc/self/statm";
21  FILE* fd = fopen(filename, "r");
22  if (0==fd) {
23  char errbuf[1024];
24  strerror_r (errno, errbuf, sizeof(errbuf));
25  fprintf(stderr,
26  "read_statm: problem opening file %s:\n%s\n", filename, errbuf);
27  return res;
28  }
29 
30  if (fscanf(fd, "%80u %80u", &res.vm_pages, &res.rss_pages) < 2) {
31  fprintf(stderr,
32  "read_statm: problem reading file %s:\n", filename);
33  }
34  fclose(fd);
35 #else
36  int pagesize = getpagesize();
37  struct task_basic_info t_info;
38  mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
39  if (KERN_SUCCESS == task_info(mach_task_self(),
40  TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count)) {
41  // On the Mac, the virtual and resident sizes are returned in units of bytes
42  // whereas CoreDumpSvc expects them to be returned in units of pages
43  res.vm_pages = t_info.virtual_size/pagesize;
44  res.rss_pages = t_info.resident_size/pagesize;
45  }
46 #endif
47  return res;
48 }
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:11
ReadFromCoolCompare.fd
fd
Definition: ReadFromCoolCompare.py:196
athena_statm
Definition: read_athena_statm.h:13
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:23