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

Side by Side Diff: base/process_util_posix.cc

Issue 300010: Cleanup: change PIDs to base::ProcessId (or pid_t) (Closed)
Patch Set: Print out PID as int64 in case ProcessId type ever grows. Created 11 years, 2 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.h ('k') | chrome/app/chrome_dll_main.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) 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 return false; 70 return false;
71 } 71 }
72 72
73 bool result = kill(process_id, SIGTERM) == 0; 73 bool result = kill(process_id, SIGTERM) == 0;
74 74
75 if (result && wait) { 75 if (result && wait) {
76 int tries = 60; 76 int tries = 60;
77 // The process may not end immediately due to pending I/O 77 // The process may not end immediately due to pending I/O
78 bool exited = false; 78 bool exited = false;
79 while (tries-- > 0) { 79 while (tries-- > 0) {
80 int pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG)); 80 pid_t pid = HANDLE_EINTR(waitpid(process_id, NULL, WNOHANG));
81 if (pid == process_id) { 81 if (pid == process_id) {
82 exited = true; 82 exited = true;
83 break; 83 break;
84 } 84 }
85 85
86 sleep(1); 86 sleep(1);
87 } 87 }
88 88
89 if (!exited) { 89 if (!exited) {
90 result = kill(process_id, SIGKILL) == 0; 90 result = kill(process_id, SIGKILL) == 0;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 // On POSIX, there nothing to do AFAIK. 323 // On POSIX, there nothing to do AFAIK.
324 } 324 }
325 325
326 void RaiseProcessToHighPriority() { 326 void RaiseProcessToHighPriority() {
327 // On POSIX, we don't actually do anything here. We could try to nice() or 327 // On POSIX, we don't actually do anything here. We could try to nice() or
328 // setpriority() or sched_getscheduler, but these all require extra rights. 328 // setpriority() or sched_getscheduler, but these all require extra rights.
329 } 329 }
330 330
331 bool DidProcessCrash(bool* child_exited, ProcessHandle handle) { 331 bool DidProcessCrash(bool* child_exited, ProcessHandle handle) {
332 int status; 332 int status;
333 const int result = HANDLE_EINTR(waitpid(handle, &status, WNOHANG)); 333 const pid_t result = HANDLE_EINTR(waitpid(handle, &status, WNOHANG));
334 if (result == -1) { 334 if (result == -1) {
335 PLOG(ERROR) << "waitpid(" << handle << ")"; 335 PLOG(ERROR) << "waitpid(" << handle << ")";
336 if (child_exited) 336 if (child_exited)
337 *child_exited = false; 337 *child_exited = false;
338 return false; 338 return false;
339 } else if (result == 0) { 339 } else if (result == 0) {
340 // the child hasn't exited yet. 340 // the child hasn't exited yet.
341 if (child_exited) 341 if (child_exited)
342 *child_exited = false; 342 *child_exited = false;
343 return false; 343 return false;
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 const ProcessFilter* filter) { 638 const ProcessFilter* filter) {
639 bool exited_cleanly = 639 bool exited_cleanly =
640 WaitForProcessesToExit(executable_name, wait_milliseconds, 640 WaitForProcessesToExit(executable_name, wait_milliseconds,
641 filter); 641 filter);
642 if (!exited_cleanly) 642 if (!exited_cleanly)
643 KillProcesses(executable_name, exit_code, filter); 643 KillProcesses(executable_name, exit_code, filter);
644 return exited_cleanly; 644 return exited_cleanly;
645 } 645 }
646 646
647 } // namespace base 647 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util.h ('k') | chrome/app/chrome_dll_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698