OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/process_util.h" | 5 #include "base/process_util.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
10 #include <sys/time.h> | 10 #include <sys/time.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace base { | 23 namespace base { |
24 | 24 |
25 int GetCurrentProcId() { | 25 int GetCurrentProcId() { |
26 return getpid(); | 26 return getpid(); |
27 } | 27 } |
28 | 28 |
29 ProcessHandle GetCurrentProcessHandle() { | 29 ProcessHandle GetCurrentProcessHandle() { |
30 return GetCurrentProcId(); | 30 return GetCurrentProcId(); |
31 } | 31 } |
32 | 32 |
33 bool CloseProcessHandle(ProcessHandle process) { | |
34 return true; | |
35 } | |
36 | |
37 int GetProcId(ProcessHandle process) { | 33 int GetProcId(ProcessHandle process) { |
38 return process; | 34 return process; |
39 } | 35 } |
40 | 36 |
41 // Attempts to kill the process identified by the given process | 37 // Attempts to kill the process identified by the given process |
42 // entry structure. Ignores specified exit_code; posix can't force that. | 38 // entry structure. Ignores specified exit_code; posix can't force that. |
43 // Returns true if this is successful, false otherwise. | 39 // Returns true if this is successful, false otherwise. |
44 bool KillProcess(int process_id, int exit_code, bool wait) { | 40 bool KillProcess(int process_id, int exit_code, bool wait) { |
45 bool result = false; | 41 bool result = false; |
46 | 42 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 int cpu = static_cast<int>((system_time_delta * 100 + time_delta / 2) / | 235 int cpu = static_cast<int>((system_time_delta * 100 + time_delta / 2) / |
240 time_delta); | 236 time_delta); |
241 | 237 |
242 last_system_time_ = system_time; | 238 last_system_time_ = system_time; |
243 last_time_ = time; | 239 last_time_ = time; |
244 | 240 |
245 return cpu; | 241 return cpu; |
246 } | 242 } |
247 | 243 |
248 } // namespace base | 244 } // namespace base |
OLD | NEW |