OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/process/kill.h" | 5 #include "base/process/kill.h" |
6 | 6 |
7 #include <signal.h> | 7 #include <signal.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include <sys/wait.h> | 9 #include <sys/wait.h> |
10 #include <unistd.h> | 10 #include <unistd.h> |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // A thread class which waits for the given child to exit and reaps it. | 403 // A thread class which waits for the given child to exit and reaps it. |
404 // If the child doesn't exit within a couple of seconds, kill it. | 404 // If the child doesn't exit within a couple of seconds, kill it. |
405 class BackgroundReaper : public PlatformThread::Delegate { | 405 class BackgroundReaper : public PlatformThread::Delegate { |
406 public: | 406 public: |
407 BackgroundReaper(pid_t child, unsigned timeout) | 407 BackgroundReaper(pid_t child, unsigned timeout) |
408 : child_(child), | 408 : child_(child), |
409 timeout_(timeout) { | 409 timeout_(timeout) { |
410 } | 410 } |
411 | 411 |
412 // Overridden from PlatformThread::Delegate: | 412 // Overridden from PlatformThread::Delegate: |
413 virtual void ThreadMain() OVERRIDE { | 413 void ThreadMain() override { |
414 WaitForChildToDie(); | 414 WaitForChildToDie(); |
415 delete this; | 415 delete this; |
416 } | 416 } |
417 | 417 |
418 void WaitForChildToDie() { | 418 void WaitForChildToDie() { |
419 // Wait forever case. | 419 // Wait forever case. |
420 if (timeout_ == 0) { | 420 if (timeout_ == 0) { |
421 pid_t r = HANDLE_EINTR(waitpid(child_, NULL, 0)); | 421 pid_t r = HANDLE_EINTR(waitpid(child_, NULL, 0)); |
422 if (r != child_) { | 422 if (r != child_) { |
423 DPLOG(ERROR) << "While waiting for " << child_ | 423 DPLOG(ERROR) << "While waiting for " << child_ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 if (IsChildDead(process)) | 473 if (IsChildDead(process)) |
474 return; | 474 return; |
475 | 475 |
476 BackgroundReaper* reaper = new BackgroundReaper(process, 0); | 476 BackgroundReaper* reaper = new BackgroundReaper(process, 0); |
477 PlatformThread::CreateNonJoinable(0, reaper); | 477 PlatformThread::CreateNonJoinable(0, reaper); |
478 } | 478 } |
479 | 479 |
480 #endif // !defined(OS_MACOSX) | 480 #endif // !defined(OS_MACOSX) |
481 | 481 |
482 } // namespace base | 482 } // namespace base |
OLD | NEW |