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

Unified Diff: base/process_util_posix.cc

Issue 18447: Share DidProcessCrash between Linux and Mac. (Closed)
Patch Set: Created 11 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process_util_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_posix.cc
diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc
index 8e6781e553000a75ce178f5965af5ecca68cf4aa..87a4e36ae88d4874859ce2989838a9a040d24e42 100644
--- a/base/process_util_posix.cc
+++ b/base/process_util_posix.cc
@@ -97,6 +97,31 @@ void RaiseProcessToHighPriority() {
// setpriority() or sched_getscheduler, but these all require extra rights.
}
+bool DidProcessCrash(ProcessHandle handle) {
+ int status;
+ if (waitpid(handle, &status, WNOHANG)) {
+ // I feel like dancing!
+ return false;
+ }
+
+ if (WIFSIGNALED(status)) {
+ switch(WTERMSIG(status)) {
+ case SIGSEGV:
Mark Mentovai 2009/01/21 14:20:22 SIGBUS?
+ case SIGILL:
+ case SIGABRT:
+ case SIGFPE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ if (WIFEXITED(status))
+ return WEXITSTATUS(status) != 0;
Mark Mentovai 2009/01/21 14:20:22 That's not really a crash, though...
+
+ return false;
+}
+
bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
int status;
while (waitpid(handle, &status, 0) == -1) {
« no previous file with comments | « base/process_util_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698