| 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 BASE_API TerminationStatus GetTerminationStatus(ProcessHandle handle, | 366 BASE_API TerminationStatus GetTerminationStatus(ProcessHandle handle, |
| 367 int* exit_code); | 367 int* exit_code); |
| 368 | 368 |
| 369 // Waits for process to exit. On POSIX systems, if the process hasn't been | 369 // Waits for process to exit. On POSIX systems, if the process hasn't been |
| 370 // signaled then puts the exit code in |exit_code|; otherwise it's considered | 370 // signaled then puts the exit code in |exit_code|; otherwise it's considered |
| 371 // a failure. On Windows |exit_code| is always filled. Returns true on success, | 371 // a failure. On Windows |exit_code| is always filled. Returns true on success, |
| 372 // and closes |handle| in any case. | 372 // and closes |handle| in any case. |
| 373 BASE_API bool WaitForExitCode(ProcessHandle handle, int* exit_code); | 373 BASE_API bool WaitForExitCode(ProcessHandle handle, int* exit_code); |
| 374 | 374 |
| 375 // Waits for process to exit. If it did exit within |timeout_milliseconds|, | 375 // Waits for process to exit. If it did exit within |timeout_milliseconds|, |
| 376 // then puts the exit code in |exit_code|, and returns true. | 376 // then puts the exit code in |exit_code|, closes |handle|, and returns true. |
| 377 // In POSIX systems, if the process has been signaled then |exit_code| is set | 377 // In POSIX systems, if the process has been signaled then |exit_code| is set |
| 378 // to -1. Returns false on failure (the caller is then responsible for closing | 378 // to -1. Returns false on failure (the caller is then responsible for closing |
| 379 // |handle|). | 379 // |handle|). |
| 380 // The caller is always responsible for closing the |handle|. | |
| 381 BASE_API bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, | 380 BASE_API bool WaitForExitCodeWithTimeout(ProcessHandle handle, int* exit_code, |
| 382 int64 timeout_milliseconds); | 381 int64 timeout_milliseconds); |
| 383 | 382 |
| 384 // Wait for all the processes based on the named executable to exit. If filter | 383 // Wait for all the processes based on the named executable to exit. If filter |
| 385 // is non-null, then only processes selected by the filter are waited on. | 384 // is non-null, then only processes selected by the filter are waited on. |
| 386 // Returns after all processes have exited or wait_milliseconds have expired. | 385 // Returns after all processes have exited or wait_milliseconds have expired. |
| 387 // Returns true if all the processes exited, false otherwise. | 386 // Returns true if all the processes exited, false otherwise. |
| 388 BASE_API bool WaitForProcessesToExit( | 387 BASE_API bool WaitForProcessesToExit( |
| 389 const FilePath::StringType& executable_name, | 388 const FilePath::StringType& executable_name, |
| 390 int64 wait_milliseconds, | 389 int64 wait_milliseconds, |
| 391 const ProcessFilter* filter); | 390 const ProcessFilter* filter); |
| 392 | 391 |
| 393 // Wait for a single process to exit. Return true if it exited cleanly within | 392 // Wait for a single process to exit. Return true if it exited cleanly within |
| 394 // the given time limit. On Linux |handle| must be a child process, however | 393 // the given time limit. On Linux |handle| must be a child process, however |
| 395 // on Mac and Windows it can be any process. | 394 // on Mac and Windows it can be any process. |
| 396 BASE_API bool WaitForSingleProcess(ProcessHandle handle, | 395 BASE_API bool WaitForSingleProcess(ProcessHandle handle, |
| 397 int64 wait_milliseconds); | 396 int64 wait_milliseconds); |
| 398 | 397 |
| 398 // Returns true when |wait_milliseconds| have elapsed and the process |
| 399 // is still running. |
| 400 BASE_API bool CrashAwareSleep(ProcessHandle handle, int64 wait_milliseconds); |
| 401 |
| 399 // Waits a certain amount of time (can be 0) for all the processes with a given | 402 // Waits a certain amount of time (can be 0) for all the processes with a given |
| 400 // executable name to exit, then kills off any of them that are still around. | 403 // executable name to exit, then kills off any of them that are still around. |
| 401 // If filter is non-null, then only processes selected by the filter are waited | 404 // If filter is non-null, then only processes selected by the filter are waited |
| 402 // on. Killed processes are ended with the given exit code. Returns false if | 405 // on. Killed processes are ended with the given exit code. Returns false if |
| 403 // any processes needed to be killed, true if they all exited cleanly within | 406 // any processes needed to be killed, true if they all exited cleanly within |
| 404 // the wait_milliseconds delay. | 407 // the wait_milliseconds delay. |
| 405 BASE_API bool CleanupProcesses(const FilePath::StringType& executable_name, | 408 BASE_API bool CleanupProcesses(const FilePath::StringType& executable_name, |
| 406 int64 wait_milliseconds, | 409 int64 wait_milliseconds, |
| 407 int exit_code, | 410 int exit_code, |
| 408 const ProcessFilter* filter); | 411 const ProcessFilter* filter); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // instance running inside the parent. The parent's Breakpad instance should | 676 // instance running inside the parent. The parent's Breakpad instance should |
| 674 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler | 677 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler |
| 675 // in the child after forking will restore the standard exception handler. | 678 // in the child after forking will restore the standard exception handler. |
| 676 // See http://crbug.com/20371/ for more details. | 679 // See http://crbug.com/20371/ for more details. |
| 677 void RestoreDefaultExceptionHandler(); | 680 void RestoreDefaultExceptionHandler(); |
| 678 #endif // defined(OS_MACOSX) | 681 #endif // defined(OS_MACOSX) |
| 679 | 682 |
| 680 } // namespace base | 683 } // namespace base |
| 681 | 684 |
| 682 #endif // BASE_PROCESS_UTIL_H_ | 685 #endif // BASE_PROCESS_UTIL_H_ |
| OLD | NEW |