Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: base/process_util.h

Issue 5172009: This adds some plumbing for propagating the reason for a renderer's death (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing windows includes Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/process_util_posix.cc » ('j') | chrome/browser/zygote_host_linux.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #pragma once 10 #pragma once
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const uint32 kProcessAccessDuplicateHandle = 0; 111 const uint32 kProcessAccessDuplicateHandle = 0;
112 const uint32 kProcessAccessCreateProcess = 0; 112 const uint32 kProcessAccessCreateProcess = 0;
113 const uint32 kProcessAccessSetQuota = 0; 113 const uint32 kProcessAccessSetQuota = 0;
114 const uint32 kProcessAccessSetInformation = 0; 114 const uint32 kProcessAccessSetInformation = 0;
115 const uint32 kProcessAccessQueryInformation = 0; 115 const uint32 kProcessAccessQueryInformation = 0;
116 const uint32 kProcessAccessSuspendResume = 0; 116 const uint32 kProcessAccessSuspendResume = 0;
117 const uint32 kProcessAccessQueryLimitedInfomation = 0; 117 const uint32 kProcessAccessQueryLimitedInfomation = 0;
118 const uint32 kProcessAccessWaitForTermination = 0; 118 const uint32 kProcessAccessWaitForTermination = 0;
119 #endif // defined(OS_POSIX) 119 #endif // defined(OS_POSIX)
120 120
121 // A minimalistic but hopefully cross-platform set of exit codes. 121 // Return status values from GetTerminationStatus. Don't use these as
122 // Do not change the enumeration values or you will break third-party 122 // exit code arguments to KillProcess*(), use platform/application
123 // installers. 123 // specific values instead.
124 enum { 124 enum TerminationStatus {
125 PROCESS_END_NORMAL_TERMINATION = 0, 125 TERMINATION_STATUS_NORMAL_TERMINATION, // zero exit status
126 PROCESS_END_KILLED_BY_USER = 1, 126 TERMINATION_STATUS_ABNORMAL_TERMINATION, // non-zero exit status
127 PROCESS_END_PROCESS_WAS_HUNG = 2 127 TERMINATION_STATUS_PROCESS_WAS_KILLED, // e.g. SIGKILL or task manager kill
128 TERMINATION_STATUS_PROCESS_CRASHED, // e.g. Segmentation fault
129 TERMINATION_STATUS_STILL_RUNNING // child hasn't exited yet
128 }; 130 };
129 131
130 // Returns the id of the current process. 132 // Returns the id of the current process.
131 ProcessId GetCurrentProcId(); 133 ProcessId GetCurrentProcId();
132 134
133 // Returns the ProcessHandle of the current process. 135 // Returns the ProcessHandle of the current process.
134 ProcessHandle GetCurrentProcessHandle(); 136 ProcessHandle GetCurrentProcessHandle();
135 137
136 // Converts a PID to a process handle. This handle must be closed by 138 // Converts a PID to a process handle. This handle must be closed by
137 // CloseProcessHandle when you are done with it. Returns true on success. 139 // CloseProcessHandle when you are done with it. Returns true on success.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 175
174 static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score"; 176 static const char kAdjustOOMScoreSwitch[] = "--adjust-oom-score";
175 177
176 // This adjusts /proc/process/oom_adj so the Linux OOM killer will prefer 178 // This adjusts /proc/process/oom_adj so the Linux OOM killer will prefer
177 // certain process types over others. The range for the adjustment is 179 // certain process types over others. The range for the adjustment is
178 // [-17,15], with [0,15] being user accessible. 180 // [-17,15], with [0,15] being user accessible.
179 bool AdjustOOMScore(ProcessId process, int score); 181 bool AdjustOOMScore(ProcessId process, int score);
180 #endif 182 #endif
181 183
182 #if defined(OS_POSIX) 184 #if defined(OS_POSIX)
183 // Close all file descriptors, expect those which are a destination in the 185 // Close all file descriptors, except those which are a destination in the
184 // given multimap. Only call this function in a child process where you know 186 // given multimap. Only call this function in a child process where you know
185 // that there aren't any other threads. 187 // that there aren't any other threads.
186 void CloseSuperfluousFds(const InjectiveMultimap& saved_map); 188 void CloseSuperfluousFds(const InjectiveMultimap& saved_map);
187 #endif 189 #endif
188 190
189 #if defined(OS_WIN) 191 #if defined(OS_WIN)
190 192
191 enum IntegrityLevel { 193 enum IntegrityLevel {
192 INTEGRITY_UNKNOWN, 194 INTEGRITY_UNKNOWN,
193 LOW_INTEGRITY, 195 LOW_INTEGRITY,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 #if defined(OS_POSIX) 342 #if defined(OS_POSIX)
341 // Attempts to kill the process group identified by |process_group_id|. Returns 343 // Attempts to kill the process group identified by |process_group_id|. Returns
342 // true on success. 344 // true on success.
343 bool KillProcessGroup(ProcessHandle process_group_id); 345 bool KillProcessGroup(ProcessHandle process_group_id);
344 #endif 346 #endif
345 347
346 #if defined(OS_WIN) 348 #if defined(OS_WIN)
347 bool KillProcessById(ProcessId process_id, int exit_code, bool wait); 349 bool KillProcessById(ProcessId process_id, int exit_code, bool wait);
348 #endif 350 #endif
349 351
350 // Get the termination status (exit code) of the process and return true if the 352 // Get the termination status of the process by interpreting the
351 // status indicates the process crashed. |child_exited| is set to true iff the 353 // circumstances of the child process' death. |exit_code| is set to
352 // child process has terminated. (|child_exited| may be NULL.) 354 // the status returned by waitpid() on POSIX, and from
353 bool DidProcessCrash(bool* child_exited, ProcessHandle handle); 355 // GetExitCodeProcess() on Windows. |exit_code| may be NULL if the
356 // caller is not interested in it.
brettw 2010/12/13 21:09:35 On Linux, is my understanding correct that this fu
Greg Spencer (Chromium) 2010/12/13 22:36:16 Done.
357 TerminationStatus GetTerminationStatus(ProcessHandle handle, int* exit_code);
354 358
355 // Waits for process to exit. In POSIX systems, if the process hasn't been 359 // Waits for process to exit. In POSIX systems, if the process hasn't been
356 // signaled then puts the exit code in |exit_code|; otherwise it's considered 360 // signaled then puts the exit code in |exit_code|; otherwise it's considered
357 // a failure. On Windows |exit_code| is always filled. Returns true on success, 361 // a failure. On Windows |exit_code| is always filled. Returns true on success,
358 // and closes |handle| in any case. 362 // and closes |handle| in any case.
359 bool WaitForExitCode(ProcessHandle handle, int* exit_code); 363 bool WaitForExitCode(ProcessHandle handle, int* exit_code);
360 364
361 // Waits for process to exit. If it did exit within |timeout_milliseconds|, 365 // Waits for process to exit. If it did exit within |timeout_milliseconds|,
362 // then puts the exit code in |exit_code|, closes |handle|, and returns true. 366 // then puts the exit code in |exit_code|, closes |handle|, and returns true.
363 // In POSIX systems, if the process has been signaled then |exit_code| is set 367 // In POSIX systems, if the process has been signaled then |exit_code| is set
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // instance running inside the parent. The parent's Breakpad instance should 666 // instance running inside the parent. The parent's Breakpad instance should
663 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler 667 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler
664 // in the child after forking will restore the standard exception handler. 668 // in the child after forking will restore the standard exception handler.
665 // See http://crbug.com/20371/ for more details. 669 // See http://crbug.com/20371/ for more details.
666 void RestoreDefaultExceptionHandler(); 670 void RestoreDefaultExceptionHandler();
667 #endif // defined(OS_MACOSX) 671 #endif // defined(OS_MACOSX)
668 672
669 } // namespace base 673 } // namespace base
670 674
671 #endif // BASE_PROCESS_UTIL_H_ 675 #endif // BASE_PROCESS_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/process_util_posix.cc » ('j') | chrome/browser/zygote_host_linux.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698