OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // This file/namespace contains utility functions for enumerating, ending and | 5 // This file/namespace contains utility functions for enumerating, ending and |
6 // computing statistics of processes. | 6 // computing statistics of processes. |
7 | 7 |
8 #ifndef BASE_PROCESS_UTIL_H_ | 8 #ifndef BASE_PROCESS_UTIL_H_ |
9 #define BASE_PROCESS_UTIL_H_ | 9 #define BASE_PROCESS_UTIL_H_ |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 }; | 37 }; |
38 | 38 |
39 struct IoCounters { | 39 struct IoCounters { |
40 unsigned long long ReadOperationCount; | 40 unsigned long long ReadOperationCount; |
41 unsigned long long WriteOperationCount; | 41 unsigned long long WriteOperationCount; |
42 unsigned long long OtherOperationCount; | 42 unsigned long long OtherOperationCount; |
43 unsigned long long ReadTransferCount; | 43 unsigned long long ReadTransferCount; |
44 unsigned long long WriteTransferCount; | 44 unsigned long long WriteTransferCount; |
45 unsigned long long OtherTransferCount; | 45 unsigned long long OtherTransferCount; |
46 }; | 46 }; |
| 47 |
| 48 #include "base/file_descriptor_shuffle.h" |
47 #endif | 49 #endif |
48 | 50 |
49 #if defined(OS_MACOSX) | 51 #if defined(OS_MACOSX) |
50 struct kinfo_proc; | 52 struct kinfo_proc; |
51 #endif | 53 #endif |
52 | 54 |
53 namespace base { | 55 namespace base { |
54 | 56 |
55 // A minimalistic but hopefully cross-platform set of exit codes. | 57 // A minimalistic but hopefully cross-platform set of exit codes. |
56 // Do not change the enumeration values or you will break third-party | 58 // Do not change the enumeration values or you will break third-party |
(...skipping 18 matching lines...) Expand all Loading... |
75 void CloseProcessHandle(ProcessHandle process); | 77 void CloseProcessHandle(ProcessHandle process); |
76 | 78 |
77 // Returns the unique ID for the specified process. This is functionally the | 79 // Returns the unique ID for the specified process. This is functionally the |
78 // same as Windows' GetProcessId(), but works on versions of Windows before | 80 // same as Windows' GetProcessId(), but works on versions of Windows before |
79 // Win XP SP1 as well. | 81 // Win XP SP1 as well. |
80 ProcessId GetProcId(ProcessHandle process); | 82 ProcessId GetProcId(ProcessHandle process); |
81 | 83 |
82 #if defined(OS_POSIX) | 84 #if defined(OS_POSIX) |
83 // Sets all file descriptors to close on exec except for stdin, stdout | 85 // Sets all file descriptors to close on exec except for stdin, stdout |
84 // and stderr. | 86 // and stderr. |
| 87 // TODO(agl): remove this function |
| 88 // WARNING: do not use. It's inherently race-prone in the face of |
| 89 // multi-threading. |
85 void SetAllFDsToCloseOnExec(); | 90 void SetAllFDsToCloseOnExec(); |
| 91 // Close all file descriptors, expect those which are a destination in the |
| 92 // given multimap. Only call this function in a child process where you know |
| 93 // that there aren't any other threads. |
| 94 void CloseSuperfluousFds(const base::InjectiveMultimap& saved_map); |
86 #endif | 95 #endif |
87 | 96 |
88 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
89 // Runs the given application name with the given command line. Normally, the | 98 // Runs the given application name with the given command line. Normally, the |
90 // first command line argument should be the path to the process, and don't | 99 // first command line argument should be the path to the process, and don't |
91 // forget to quote it. | 100 // forget to quote it. |
92 // | 101 // |
93 // If wait is true, it will block and wait for the other process to finish, | 102 // If wait is true, it will block and wait for the other process to finish, |
94 // otherwise, it will just continue asynchronously. | 103 // otherwise, it will just continue asynchronously. |
95 // | 104 // |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // overflow. Has no effect if the OS doesn't provide the necessary facility. | 381 // overflow. Has no effect if the OS doesn't provide the necessary facility. |
373 void EnableTerminationOnHeapCorruption(); | 382 void EnableTerminationOnHeapCorruption(); |
374 | 383 |
375 // If supported on the platform, and the user has sufficent rights, increase | 384 // If supported on the platform, and the user has sufficent rights, increase |
376 // the current process's scheduling priority to a high priority. | 385 // the current process's scheduling priority to a high priority. |
377 void RaiseProcessToHighPriority(); | 386 void RaiseProcessToHighPriority(); |
378 | 387 |
379 } // namespace base | 388 } // namespace base |
380 | 389 |
381 #endif // BASE_PROCESS_UTIL_H_ | 390 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |