diff options
Diffstat (limited to 'util/processinfo_darwin.cpp')
-rw-r--r-- | util/processinfo_darwin.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/util/processinfo_darwin.cpp b/util/processinfo_darwin.cpp index cb54bed..c1190ae 100644 --- a/util/processinfo_darwin.cpp +++ b/util/processinfo_darwin.cpp @@ -36,58 +36,58 @@ using namespace std; namespace mongo { - - ProcessInfo::ProcessInfo( pid_t pid ) : _pid( pid ){ + + ProcessInfo::ProcessInfo( pid_t pid ) : _pid( pid ) { } - ProcessInfo::~ProcessInfo(){ + ProcessInfo::~ProcessInfo() { } - bool ProcessInfo::supported(){ + bool ProcessInfo::supported() { return true; } - - int ProcessInfo::getVirtualMemorySize(){ + + int ProcessInfo::getVirtualMemorySize() { task_t result; - + mach_port_t task; - - if ( ( result = task_for_pid( mach_task_self() , _pid , &task) ) != KERN_SUCCESS ){ + + if ( ( result = task_for_pid( mach_task_self() , _pid , &task) ) != KERN_SUCCESS ) { cout << "error getting task\n"; return 0; } - + #if !defined(__LP64__) task_basic_info_32 ti; #else task_basic_info_64 ti; #endif mach_msg_type_number_t count = TASK_BASIC_INFO_COUNT; - if ( ( result = task_info( task , TASK_BASIC_INFO , (task_info_t)&ti, &count ) ) != KERN_SUCCESS ){ + if ( ( result = task_info( task , TASK_BASIC_INFO , (task_info_t)&ti, &count ) ) != KERN_SUCCESS ) { cout << "error getting task_info: " << result << endl; return 0; } return (int)((double)ti.virtual_size / (1024.0 * 1024 ) ); } - - int ProcessInfo::getResidentSize(){ + + int ProcessInfo::getResidentSize() { task_t result; - + mach_port_t task; - - if ( ( result = task_for_pid( mach_task_self() , _pid , &task) ) != KERN_SUCCESS ){ + + if ( ( result = task_for_pid( mach_task_self() , _pid , &task) ) != KERN_SUCCESS ) { cout << "error getting task\n"; return 0; } - - + + #if !defined(__LP64__) task_basic_info_32 ti; #else task_basic_info_64 ti; #endif mach_msg_type_number_t count = TASK_BASIC_INFO_COUNT; - if ( ( result = task_info( task , TASK_BASIC_INFO , (task_info_t)&ti, &count ) ) != KERN_SUCCESS ){ + if ( ( result = task_info( task , TASK_BASIC_INFO , (task_info_t)&ti, &count ) ) != KERN_SUCCESS ) { cout << "error getting task_info: " << result << endl; return 0; } @@ -96,18 +96,18 @@ namespace mongo { void ProcessInfo::getExtraInfo(BSONObjBuilder& info) {} - bool ProcessInfo::blockCheckSupported(){ + bool ProcessInfo::blockCheckSupported() { return true; } - - bool ProcessInfo::blockInMemory( char * start ){ + + bool ProcessInfo::blockInMemory( char * start ) { static long pageSize = 0; - if ( pageSize == 0 ){ + if ( pageSize == 0 ) { pageSize = sysconf( _SC_PAGESIZE ); } start = start - ( (unsigned long long)start % pageSize ); char x = 0; - if ( mincore( start , 128 , &x ) ){ + if ( mincore( start , 128 , &x ) ) { log() << "mincore failed: " << errnoWithDescription() << endl; return 1; } |