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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 const pid_t child_; | 456 const pid_t child_; |
457 // Number of seconds to wait, if 0 then wait forever and do not attempt to | 457 // Number of seconds to wait, if 0 then wait forever and do not attempt to |
458 // kill |child_|. | 458 // kill |child_|. |
459 const unsigned timeout_; | 459 const unsigned timeout_; |
460 | 460 |
461 DISALLOW_COPY_AND_ASSIGN(BackgroundReaper); | 461 DISALLOW_COPY_AND_ASSIGN(BackgroundReaper); |
462 }; | 462 }; |
463 | 463 |
464 } // namespace | 464 } // namespace |
465 | 465 |
466 void EnsureProcessTerminated(ProcessHandle process) { | 466 void EnsureProcessTerminated(Process process) { |
467 // If the child is already dead, then there's nothing to do. | 467 // If the child is already dead, then there's nothing to do. |
468 if (IsChildDead(process)) | 468 if (IsChildDead(process.pid())) |
469 return; | 469 return; |
470 | 470 |
471 const unsigned timeout = 2; // seconds | 471 const unsigned timeout = 2; // seconds |
472 BackgroundReaper* reaper = new BackgroundReaper(process, timeout); | 472 BackgroundReaper* reaper = new BackgroundReaper(process.pid(), timeout); |
473 PlatformThread::CreateNonJoinable(0, reaper); | 473 PlatformThread::CreateNonJoinable(0, reaper); |
474 } | 474 } |
475 | 475 |
476 void EnsureProcessGetsReaped(ProcessHandle process) { | 476 void EnsureProcessGetsReaped(ProcessHandle process) { |
477 // If the child is already dead, then there's nothing to do. | 477 // If the child is already dead, then there's nothing to do. |
478 if (IsChildDead(process)) | 478 if (IsChildDead(process)) |
479 return; | 479 return; |
480 | 480 |
481 BackgroundReaper* reaper = new BackgroundReaper(process, 0); | 481 BackgroundReaper* reaper = new BackgroundReaper(process, 0); |
482 PlatformThread::CreateNonJoinable(0, reaper); | 482 PlatformThread::CreateNonJoinable(0, reaper); |
483 } | 483 } |
484 | 484 |
485 #endif // !defined(OS_MACOSX) | 485 #endif // !defined(OS_MACOSX) |
486 #endif // !defined(OS_NACL_NONSFI) | 486 #endif // !defined(OS_NACL_NONSFI) |
487 | 487 |
488 } // namespace base | 488 } // namespace base |
OLD | NEW |