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

Side by Side Diff: chrome/common/process_watcher_posix.cc

Issue 1432003: Minor C++ fixes found by Clang. (Closed)
Patch Set: rebase Created 10 years, 9 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/common/process_watcher.h" 5 #include "chrome/common/process_watcher.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <sys/wait.h> 10 #include <sys/wait.h>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // Wait for 2 * timeout_ 500 milliseconds intervals. 58 // Wait for 2 * timeout_ 500 milliseconds intervals.
59 for (unsigned i = 0; i < 2 * timeout_; ++i) { 59 for (unsigned i = 0; i < 2 * timeout_; ++i) {
60 PlatformThread::Sleep(500); // 0.5 seconds 60 PlatformThread::Sleep(500); // 0.5 seconds
61 if (IsChildDead(child_)) 61 if (IsChildDead(child_))
62 return; 62 return;
63 } 63 }
64 64
65 if (kill(child_, SIGKILL) == 0) { 65 if (kill(child_, SIGKILL) == 0) {
66 // SIGKILL is uncatchable. Since the signal was delivered, we can 66 // SIGKILL is uncatchable. Since the signal was delivered, we can
67 // just wait for the process to die now in a blocking manner. 67 // just wait for the process to die now in a blocking manner.
68 HANDLE_EINTR(waitpid(child_, NULL, 0)); 68 if (HANDLE_EINTR(waitpid(child_, NULL, 0)) < 0)
69 PLOG(WARNING) << "waitpid";
willchan no longer on Chromium 2010/03/30 17:13:18 Hm, we should probably #include "base/logging.h" f
69 } else { 70 } else {
70 LOG(ERROR) << "While waiting for " << child_ << " to terminate we" 71 LOG(ERROR) << "While waiting for " << child_ << " to terminate we"
71 << " failed to deliver a SIGKILL signal (" << errno << ")."; 72 << " failed to deliver a SIGKILL signal (" << errno << ").";
72 } 73 }
73 } 74 }
74 75
75 private: 76 private:
76 const pid_t child_; 77 const pid_t child_;
77 // Number of seconds to wait, if 0 then wait forever and do not attempt to 78 // Number of seconds to wait, if 0 then wait forever and do not attempt to
78 // kill |child_|. 79 // kill |child_|.
(...skipping 15 matching lines...) Expand all
94 95
95 // static 96 // static
96 void ProcessWatcher::EnsureProcessGetsReaped(base::ProcessHandle process) { 97 void ProcessWatcher::EnsureProcessGetsReaped(base::ProcessHandle process) {
97 // If the child is already dead, then there's nothing to do. 98 // If the child is already dead, then there's nothing to do.
98 if (IsChildDead(process)) 99 if (IsChildDead(process))
99 return; 100 return;
100 101
101 BackgroundReaper* reaper = new BackgroundReaper(process, 0); 102 BackgroundReaper* reaper = new BackgroundReaper(process, 0);
102 PlatformThread::CreateNonJoinable(0, reaper); 103 PlatformThread::CreateNonJoinable(0, reaper);
103 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698