| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
| 6 | 6 |
| 7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
| 8 #if defined(HOST_OS_MACOS) | 8 #if defined(HOST_OS_MACOS) |
| 9 | 9 |
| 10 #include "bin/process.h" | 10 #include "bin/process.h" |
| 11 | 11 |
| 12 #if !HOST_OS_IOS | 12 #if !HOST_OS_IOS |
| 13 #include <crt_externs.h> // NOLINT | 13 #include <crt_externs.h> // NOLINT |
| 14 #endif | 14 #endif |
| 15 #include <errno.h> // NOLINT | 15 #include <errno.h> // NOLINT |
| 16 #include <fcntl.h> // NOLINT | 16 #include <fcntl.h> // NOLINT |
| 17 #include <mach/mach.h> // NOLINT |
| 17 #include <poll.h> // NOLINT | 18 #include <poll.h> // NOLINT |
| 18 #include <signal.h> // NOLINT | 19 #include <signal.h> // NOLINT |
| 19 #include <stdio.h> // NOLINT | 20 #include <stdio.h> // NOLINT |
| 20 #include <stdlib.h> // NOLINT | 21 #include <stdlib.h> // NOLINT |
| 21 #include <string.h> // NOLINT | 22 #include <string.h> // NOLINT |
| 22 #include <unistd.h> // NOLINT | 23 #include <unistd.h> // NOLINT |
| 23 | 24 |
| 24 #include "bin/dartutils.h" | 25 #include "bin/dartutils.h" |
| 25 #include "bin/fdutils.h" | 26 #include "bin/fdutils.h" |
| 26 #include "bin/lockers.h" | 27 #include "bin/lockers.h" |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 void Process::TerminateExitCodeHandler() { | 962 void Process::TerminateExitCodeHandler() { |
| 962 ExitCodeHandler::TerminateExitCodeThread(); | 963 ExitCodeHandler::TerminateExitCodeThread(); |
| 963 } | 964 } |
| 964 | 965 |
| 965 | 966 |
| 966 intptr_t Process::CurrentProcessId() { | 967 intptr_t Process::CurrentProcessId() { |
| 967 return static_cast<intptr_t>(getpid()); | 968 return static_cast<intptr_t>(getpid()); |
| 968 } | 969 } |
| 969 | 970 |
| 970 | 971 |
| 972 int64_t Process::CurrentRSS() { |
| 973 struct mach_task_basic_info info; |
| 974 mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT; |
| 975 kern_return_t result = |
| 976 task_info(mach_task_self(), MACH_TASK_BASIC_INFO, |
| 977 reinterpret_cast<task_info_t>(&info), &infoCount); |
| 978 if (result != KERN_SUCCESS) { |
| 979 return -1; |
| 980 } |
| 981 return info.resident_size; |
| 982 } |
| 983 |
| 984 |
| 985 int64_t Process::MaxRSS() { |
| 986 struct rusage usage; |
| 987 usage.ru_maxrss = 0; |
| 988 int r = getrusage(RUSAGE_SELF, &usage); |
| 989 if (r < 0) { |
| 990 return -1; |
| 991 } |
| 992 return usage.ru_maxrss; |
| 993 } |
| 994 |
| 995 |
| 971 static Mutex* signal_mutex = new Mutex(); | 996 static Mutex* signal_mutex = new Mutex(); |
| 972 static SignalInfo* signal_handlers = NULL; | 997 static SignalInfo* signal_handlers = NULL; |
| 973 static const int kSignalsCount = 7; | 998 static const int kSignalsCount = 7; |
| 974 static const int kSignals[kSignalsCount] = { | 999 static const int kSignals[kSignalsCount] = { |
| 975 SIGHUP, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, SIGWINCH, | 1000 SIGHUP, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, SIGWINCH, |
| 976 SIGQUIT // Allow VMService to listen on SIGQUIT. | 1001 SIGQUIT // Allow VMService to listen on SIGQUIT. |
| 977 }; | 1002 }; |
| 978 | 1003 |
| 979 | 1004 |
| 980 SignalInfo::~SignalInfo() { | 1005 SignalInfo::~SignalInfo() { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); | 1111 VOID_NO_RETRY_EXPECTED(sigaction(signal, &act, NULL)); |
| 1087 } | 1112 } |
| 1088 } | 1113 } |
| 1089 | 1114 |
| 1090 } // namespace bin | 1115 } // namespace bin |
| 1091 } // namespace dart | 1116 } // namespace dart |
| 1092 | 1117 |
| 1093 #endif // defined(HOST_OS_MACOS) | 1118 #endif // defined(HOST_OS_MACOS) |
| 1094 | 1119 |
| 1095 #endif // !defined(DART_IO_DISABLED) | 1120 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |