ATLAS Offline Software
read_athena_statm.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <errno.h>
6 #include <stdio.h>
7 #include <string.h> /* strerror */
8 #include <unistd.h>
9 #ifdef __APPLE__
10 # include <mach/task_info.h>
11 # include <mach/mach.h>
12 #endif // __APPLE__
14 struct athena_statm
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  fscanf(fd, "%80u %80u", &res.vm_pages, &res.rss_pages);
31  fclose(fd);
32 #else
33  int pagesize = getpagesize();
34  struct task_basic_info t_info;
35  mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
36  if (KERN_SUCCESS == task_info(mach_task_self(),
37  TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count)) {
38  // On the Mac, the virtual and resident sizes are returned in units of bytes
39  // whereas CoreDumpSvc expects them to be returned in units of pages
40  res.vm_pages = t_info.virtual_size/pagesize;
41  res.rss_pages = t_info.resident_size/pagesize;
42  }
43 #endif
44  return res;
45 }
46 
read_athena_statm
struct athena_statm read_athena_statm()
Definition: read_athena_statm.cxx:15
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
ReadFromCoolCompare.fd
fd
Definition: ReadFromCoolCompare.py:196
athena_statm
Definition: read_athena_statm.h:13
read_athena_statm.h
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24