OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 | 1261 |
1262 // A thread class which waits for the given child to exit and reaps it. | 1262 // A thread class which waits for the given child to exit and reaps it. |
1263 // If the child doesn't exit within a couple of seconds, kill it. | 1263 // If the child doesn't exit within a couple of seconds, kill it. |
1264 class BackgroundReaper : public PlatformThread::Delegate { | 1264 class BackgroundReaper : public PlatformThread::Delegate { |
1265 public: | 1265 public: |
1266 BackgroundReaper(pid_t child, unsigned timeout) | 1266 BackgroundReaper(pid_t child, unsigned timeout) |
1267 : child_(child), | 1267 : child_(child), |
1268 timeout_(timeout) { | 1268 timeout_(timeout) { |
1269 } | 1269 } |
1270 | 1270 |
1271 void ThreadMain() { | 1271 // Overridden from PlatformThread::Delegate: |
| 1272 virtual void ThreadMain() OVERRIDE { |
1272 WaitForChildToDie(); | 1273 WaitForChildToDie(); |
1273 delete this; | 1274 delete this; |
1274 } | 1275 } |
1275 | 1276 |
1276 void WaitForChildToDie() { | 1277 void WaitForChildToDie() { |
1277 // Wait forever case. | 1278 // Wait forever case. |
1278 if (timeout_ == 0) { | 1279 if (timeout_ == 0) { |
1279 pid_t r = HANDLE_EINTR(waitpid(child_, NULL, 0)); | 1280 pid_t r = HANDLE_EINTR(waitpid(child_, NULL, 0)); |
1280 if (r != child_) { | 1281 if (r != child_) { |
1281 DPLOG(ERROR) << "While waiting for " << child_ | 1282 DPLOG(ERROR) << "While waiting for " << child_ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 if (IsChildDead(process)) | 1332 if (IsChildDead(process)) |
1332 return; | 1333 return; |
1333 | 1334 |
1334 BackgroundReaper* reaper = new BackgroundReaper(process, 0); | 1335 BackgroundReaper* reaper = new BackgroundReaper(process, 0); |
1335 PlatformThread::CreateNonJoinable(0, reaper); | 1336 PlatformThread::CreateNonJoinable(0, reaper); |
1336 } | 1337 } |
1337 | 1338 |
1338 #endif // !defined(OS_MACOSX) | 1339 #endif // !defined(OS_MACOSX) |
1339 | 1340 |
1340 } // namespace base | 1341 } // namespace base |
OLD | NEW |