OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file/namespace contains utility functions for enumerating, ending and | 5 // This file/namespace contains utility functions for enumerating, ending and |
6 // computing statistics of processes. | 6 // computing statistics of processes. |
7 | 7 |
8 #ifndef BASE_PROCESS_UTIL_H_ | 8 #ifndef BASE_PROCESS_UTIL_H_ |
9 #define BASE_PROCESS_UTIL_H_ | 9 #define BASE_PROCESS_UTIL_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 // executable name to exit, then kills off any of them that are still around. | 492 // executable name to exit, then kills off any of them that are still around. |
493 // If filter is non-null, then only processes selected by the filter are waited | 493 // If filter is non-null, then only processes selected by the filter are waited |
494 // on. Killed processes are ended with the given exit code. Returns false if | 494 // on. Killed processes are ended with the given exit code. Returns false if |
495 // any processes needed to be killed, true if they all exited cleanly within | 495 // any processes needed to be killed, true if they all exited cleanly within |
496 // the wait_milliseconds delay. | 496 // the wait_milliseconds delay. |
497 BASE_EXPORT bool CleanupProcesses(const FilePath::StringType& executable_name, | 497 BASE_EXPORT bool CleanupProcesses(const FilePath::StringType& executable_name, |
498 int64 wait_milliseconds, | 498 int64 wait_milliseconds, |
499 int exit_code, | 499 int exit_code, |
500 const ProcessFilter* filter); | 500 const ProcessFilter* filter); |
501 | 501 |
| 502 // This method ensures that the specified process eventually terminates, and |
| 503 // then it closes the given process handle. |
| 504 // |
| 505 // It assumes that the process has already been signalled to exit, and it |
| 506 // begins by waiting a small amount of time for it to exit. If the process |
| 507 // does not appear to have exited, then this function starts to become |
| 508 // aggressive about ensuring that the process terminates. |
| 509 // |
| 510 // On Linux this method does not block the calling thread. |
| 511 // On OS X this method may block for up to 2 seconds. |
| 512 // |
| 513 // NOTE: The process handle must have been opened with the PROCESS_TERMINATE |
| 514 // and SYNCHRONIZE permissions. |
| 515 // |
| 516 BASE_EXPORT void EnsureProcessTerminated(ProcessHandle process_handle); |
| 517 |
| 518 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 519 // The nicer version of EnsureProcessTerminated() that is patient and will |
| 520 // wait for |process_handle| to finish and then reap it. |
| 521 BASE_EXPORT void EnsureProcessGetsReaped(ProcessHandle process_handle); |
| 522 #endif |
| 523 |
502 // This class provides a way to iterate through a list of processes on the | 524 // This class provides a way to iterate through a list of processes on the |
503 // current machine with a specified filter. | 525 // current machine with a specified filter. |
504 // To use, create an instance and then call NextProcessEntry() until it returns | 526 // To use, create an instance and then call NextProcessEntry() until it returns |
505 // false. | 527 // false. |
506 class BASE_EXPORT ProcessIterator { | 528 class BASE_EXPORT ProcessIterator { |
507 public: | 529 public: |
508 typedef std::list<ProcessEntry> ProcessEntries; | 530 typedef std::list<ProcessEntry> ProcessEntries; |
509 | 531 |
510 explicit ProcessIterator(const ProcessFilter* filter); | 532 explicit ProcessIterator(const ProcessFilter* filter); |
511 virtual ~ProcessIterator(); | 533 virtual ~ProcessIterator(); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 // instance running inside the parent. The parent's Breakpad instance should | 805 // instance running inside the parent. The parent's Breakpad instance should |
784 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 806 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
785 // in the child after forking will restore the standard exception handler. | 807 // in the child after forking will restore the standard exception handler. |
786 // See http://crbug.com/20371/ for more details. | 808 // See http://crbug.com/20371/ for more details. |
787 void RestoreDefaultExceptionHandler(); | 809 void RestoreDefaultExceptionHandler(); |
788 #endif // defined(OS_MACOSX) | 810 #endif // defined(OS_MACOSX) |
789 | 811 |
790 } // namespace base | 812 } // namespace base |
791 | 813 |
792 #endif // BASE_PROCESS_UTIL_H_ | 814 #endif // BASE_PROCESS_UTIL_H_ |
OLD | NEW |