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

Side by Side Diff: base/process_util_posix.cc

Issue 155130: Fix tools/valgrind/chrome_tests.sh to always use --log-file option... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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 | tools/valgrind/valgrind_test.py » ('j') | 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 <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>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 ProcessId GetProcId(ProcessHandle process) { 59 ProcessId GetProcId(ProcessHandle process) {
60 return process; 60 return process;
61 } 61 }
62 62
63 // Attempts to kill the process identified by the given process 63 // Attempts to kill the process identified by the given process
64 // entry structure. Ignores specified exit_code; posix can't force that. 64 // entry structure. Ignores specified exit_code; posix can't force that.
65 // Returns true if this is successful, false otherwise. 65 // Returns true if this is successful, false otherwise.
66 bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) { 66 bool KillProcess(ProcessHandle process_id, int exit_code, bool wait) {
67 DCHECK(process_id > 1);
68 if (process_id <= 1) {
69 LOG(ERROR) << "tried to kill process_id " << process_id;
70 return false;
71 }
72
67 bool result = kill(process_id, SIGTERM) == 0; 73 bool result = kill(process_id, SIGTERM) == 0;
68 74
69 if (result && wait) { 75 if (result && wait) {
70 int tries = 60; 76 int tries = 60;
71 // The process may not end immediately due to pending I/O 77 // The process may not end immediately due to pending I/O
72 while (tries-- > 0) { 78 while (tries-- > 0) {
73 int pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG)); 79 int pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG));
74 if (pid == process_id) 80 if (pid == process_id)
75 break; 81 break;
76 82
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 const ProcessFilter* filter) { 536 const ProcessFilter* filter) {
531 bool exited_cleanly = 537 bool exited_cleanly =
532 WaitForProcessesToExit(executable_name, wait_milliseconds, 538 WaitForProcessesToExit(executable_name, wait_milliseconds,
533 filter); 539 filter);
534 if (!exited_cleanly) 540 if (!exited_cleanly)
535 KillProcesses(executable_name, exit_code, filter); 541 KillProcesses(executable_name, exit_code, filter);
536 return exited_cleanly; 542 return exited_cleanly;
537 } 543 }
538 544
539 } // namespace base 545 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698