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

Side by Side Diff: base/process_util_posix.cc

Issue 7204002: Increase the KillProcess timeout when running under Valgrind (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <dirent.h> 5 #include <dirent.h>
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
11 #include <sys/time.h> 11 #include <sys/time.h>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 #include <sys/wait.h> 13 #include <sys/wait.h>
14 #include <unistd.h> 14 #include <unistd.h>
15 15
16 #include <limits> 16 #include <limits>
17 #include <set> 17 #include <set>
18 18
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "base/compiler_specific.h" 20 #include "base/compiler_specific.h"
21 #include "base/debug/stack_trace.h" 21 #include "base/debug/stack_trace.h"
22 #include "base/dir_reader_posix.h" 22 #include "base/dir_reader_posix.h"
23 #include "base/eintr_wrapper.h" 23 #include "base/eintr_wrapper.h"
24 #include "base/file_util.h" 24 #include "base/file_util.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/memory/scoped_ptr.h" 26 #include "base/memory/scoped_ptr.h"
27 #include "base/process_util.h" 27 #include "base/process_util.h"
28 #include "base/stringprintf.h" 28 #include "base/stringprintf.h"
29 #include "base/synchronization/waitable_event.h" 29 #include "base/synchronization/waitable_event.h"
30 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
darin (slow to review) 2011/06/17 20:54:42 nit: it seems a bit unintuitive that RunningOnValg
Timur Iskhodzhanov 2011/06/17 21:02:47 That's a good point. However, currently dynamic_an
30 #include "base/threading/platform_thread.h" 31 #include "base/threading/platform_thread.h"
31 #include "base/threading/thread_restrictions.h" 32 #include "base/threading/thread_restrictions.h"
32 #include "base/time.h" 33 #include "base/time.h"
33 34
34 #if defined(OS_MACOSX) 35 #if defined(OS_MACOSX)
35 #include <crt_externs.h> 36 #include <crt_externs.h>
36 #include <sys/event.h> 37 #include <sys/event.h>
37 #define environ (*_NSGetEnviron()) 38 #define environ (*_NSGetEnviron())
38 #else 39 #else
39 extern char** environ; 40 extern char** environ;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 DCHECK_GT(process_id, 1) << " tried to kill invalid process_id"; 217 DCHECK_GT(process_id, 1) << " tried to kill invalid process_id";
217 if (process_id <= 1) 218 if (process_id <= 1)
218 return false; 219 return false;
219 static unsigned kMaxSleepMs = 1000; 220 static unsigned kMaxSleepMs = 1000;
220 unsigned sleep_ms = 4; 221 unsigned sleep_ms = 4;
221 222
222 bool result = kill(process_id, SIGTERM) == 0; 223 bool result = kill(process_id, SIGTERM) == 0;
223 224
224 if (result && wait) { 225 if (result && wait) {
225 int tries = 60; 226 int tries = 60;
227
228 if (RunningOnValgrind()) {
darin (slow to review) 2011/06/17 20:54:42 OK... In my experience 2x might not even be enoug
Timur Iskhodzhanov 2011/06/17 21:02:47 Totally agree - average Valgrind slowdown is ~20x.
229 // Wait for some extra time when running under Valgrind since the child
230 // processes may take some time doing leak checking.
231 tries *= 2;
232 }
233
226 // The process may not end immediately due to pending I/O 234 // The process may not end immediately due to pending I/O
227 bool exited = false; 235 bool exited = false;
228 while (tries-- > 0) { 236 while (tries-- > 0) {
229 pid_t pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG)); 237 pid_t pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG));
230 if (pid == process_id) { 238 if (pid == process_id) {
231 exited = true; 239 exited = true;
232 break; 240 break;
233 } 241 }
234 if (pid == -1) { 242 if (pid == -1) {
235 if (errno == ECHILD) { 243 if (errno == ECHILD) {
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 const ProcessFilter* filter) { 1001 const ProcessFilter* filter) {
994 bool exited_cleanly = 1002 bool exited_cleanly =
995 WaitForProcessesToExit(executable_name, wait_milliseconds, 1003 WaitForProcessesToExit(executable_name, wait_milliseconds,
996 filter); 1004 filter);
997 if (!exited_cleanly) 1005 if (!exited_cleanly)
998 KillProcesses(executable_name, exit_code, filter); 1006 KillProcesses(executable_name, exit_code, filter);
999 return exited_cleanly; 1007 return exited_cleanly;
1000 } 1008 }
1001 1009
1002 } // namespace base 1010 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698