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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « base/process_util_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 void EnableTerminationOnHeapCorruption() { 91 void EnableTerminationOnHeapCorruption() {
92 // On POSIX, there nothing to do AFAIK. 92 // On POSIX, there nothing to do AFAIK.
93 } 93 }
94 94
95 void RaiseProcessToHighPriority() { 95 void RaiseProcessToHighPriority() {
96 // On POSIX, we don't actually do anything here. We could try to nice() or 96 // On POSIX, we don't actually do anything here. We could try to nice() or
97 // setpriority() or sched_getscheduler, but these all require extra rights. 97 // setpriority() or sched_getscheduler, but these all require extra rights.
98 } 98 }
99 99
100 bool DidProcessCrash(ProcessHandle handle) {
101 int status;
102 if (waitpid(handle, &status, WNOHANG)) {
103 // I feel like dancing!
104 return false;
105 }
106
107 if (WIFSIGNALED(status)) {
108 switch(WTERMSIG(status)) {
109 case SIGSEGV:
Mark Mentovai 2009/01/21 14:20:22 SIGBUS?
110 case SIGILL:
111 case SIGABRT:
112 case SIGFPE:
113 return true;
114 default:
115 return false;
116 }
117 }
118
119 if (WIFEXITED(status))
120 return WEXITSTATUS(status) != 0;
Mark Mentovai 2009/01/21 14:20:22 That's not really a crash, though...
121
122 return false;
123 }
124
100 bool WaitForExitCode(ProcessHandle handle, int* exit_code) { 125 bool WaitForExitCode(ProcessHandle handle, int* exit_code) {
101 int status; 126 int status;
102 while (waitpid(handle, &status, 0) == -1) { 127 while (waitpid(handle, &status, 0) == -1) {
103 if (errno != EINTR) { 128 if (errno != EINTR) {
104 NOTREACHED(); 129 NOTREACHED();
105 return false; 130 return false;
106 } 131 }
107 } 132 }
108 133
109 if (WIFEXITED(status)) { 134 if (WIFEXITED(status)) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 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) /
211 time_delta); 236 time_delta);
212 237
213 last_system_time_ = system_time; 238 last_system_time_ = system_time;
214 last_time_ = time; 239 last_time_ = time;
215 240
216 return cpu; 241 return cpu;
217 } 242 }
218 243
219 } // namespace base 244 } // namespace base
OLDNEW
« 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