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

Side by Side Diff: base/process_util_posix.cc

Issue 2721007: Fix ProcessSingletonWinTest using default profile.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 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 | chrome/browser/process_singleton_uitest.cc » ('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) 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 #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>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (result && wait) { 152 if (result && wait) {
153 int tries = 60; 153 int tries = 60;
154 // The process may not end immediately due to pending I/O 154 // The process may not end immediately due to pending I/O
155 bool exited = false; 155 bool exited = false;
156 while (tries-- > 0) { 156 while (tries-- > 0) {
157 pid_t pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG)); 157 pid_t pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG));
158 if (pid == process_id) { 158 if (pid == process_id) {
159 exited = true; 159 exited = true;
160 break; 160 break;
161 } 161 }
162 if (pid == -1) {
163 if (errno == ECHILD) {
164 // The wait may fail with ECHILD if another process also waited for
165 // the same pid, causing the process state to get cleaned up.
166 exited = true;
167 break;
168 }
169 DPLOG(ERROR) << "Error waiting for process " << process_id;
170 }
162 171
163 sleep(1); 172 sleep(1);
164 } 173 }
165 174
166 if (!exited) 175 if (!exited)
167 result = kill(process_id, SIGKILL) == 0; 176 result = kill(process_id, SIGKILL) == 0;
168 } 177 }
169 178
170 if (!result) 179 if (!result)
171 DPLOG(ERROR) << "Unable to terminate process " << process_id; 180 DPLOG(ERROR) << "Unable to terminate process " << process_id;
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 const ProcessFilter* filter) { 892 const ProcessFilter* filter) {
884 bool exited_cleanly = 893 bool exited_cleanly =
885 WaitForProcessesToExit(executable_name, wait_milliseconds, 894 WaitForProcessesToExit(executable_name, wait_milliseconds,
886 filter); 895 filter);
887 if (!exited_cleanly) 896 if (!exited_cleanly)
888 KillProcesses(executable_name, exit_code, filter); 897 KillProcesses(executable_name, exit_code, filter);
889 return exited_cleanly; 898 return exited_cleanly;
890 } 899 }
891 900
892 } // namespace base 901 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/process_singleton_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698