ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
CxxUtils
Root
read_athena_statm.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 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__
13
#include "
CxxUtils/read_athena_statm.h
"
14
struct
athena_statm
15
read_athena_statm
()
16
{
17
struct
athena_statm
res
= {0, 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 %80u"
, &
res
.vm_pages, &
res
.rss_pages, &
res
.shr_pages) < 3) {
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
}
49
res
std::pair< std::vector< unsigned int >, bool > res
Definition
JetGroupProductTest.cxx:11
read_athena_statm.h
read_athena_statm
struct athena_statm read_athena_statm()
Definition
read_athena_statm.cxx:15
athena_statm
Definition
read_athena_statm.h:13
Generated on
for ATLAS Offline Software by
1.17.0