diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 16:53:56 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 16:53:56 +0000 |
commit | 71c311bb926357af4adea1eb4206c3455be69c29 (patch) | |
tree | 66a7ab2c7767d1060e5e8fe5e4e33885651c3708 /chrome/common | |
parent | c08503001980b9f5f913ab9f83542fcab7e38a66 (diff) | |
download | chromium_src-71c311bb926357af4adea1eb4206c3455be69c29.zip chromium_src-71c311bb926357af4adea1eb4206c3455be69c29.tar.gz chromium_src-71c311bb926357af4adea1eb4206c3455be69c29.tar.bz2 |
Mac: ensure child processes are properly reaped -- eliminate Helper zombies.
BUG=32001
TEST=Surf a lot. Then close all Chrome/Chromium windows. Make sure there aren't any zombie Chrome/Chromium Helper processes (run "ps -Al" and look for things with status containing 'Z').
Review URL: http://codereview.chromium.org/542042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36124 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/process_watcher_mac.cc | 4 | ||||
-rw-r--r-- | chrome/common/process_watcher_unittest.cc | 18 |
2 files changed, 20 insertions, 2 deletions
diff --git a/chrome/common/process_watcher_mac.cc b/chrome/common/process_watcher_mac.cc index 2d5d185..be5b9f7 100644 --- a/chrome/common/process_watcher_mac.cc +++ b/chrome/common/process_watcher_mac.cc @@ -42,7 +42,9 @@ void WaitForChildToDie(pid_t child, unsigned timeout) { int result = HANDLE_EINTR(kevent(kq, &event_to_add, 1, NULL, 0, NULL)); if (result == -1 && errno == ESRCH) { // A "No Such Process" error is fine, the process may have died already - // and been reaped by someone else. + // and been reaped by someone else. But make sure that it was/is reaped. + // Don't report an error in case it was already reaped. + HANDLE_EINTR(waitpid(child, NULL, WNOHANG)); return; } diff --git a/chrome/common/process_watcher_unittest.cc b/chrome/common/process_watcher_unittest.cc index 505a468..af4aaa2 100644 --- a/chrome/common/process_watcher_unittest.cc +++ b/chrome/common/process_watcher_unittest.cc @@ -39,10 +39,26 @@ TEST_F(ProcessWatcherTest, DelayedTermination) { } MULTIPROCESS_TEST_MAIN(process_watcher_test_never_die) { - while(1){ + while (1) { sleep(500); } return 0; } +TEST_F(ProcessWatcherTest, ImmediateTermination) { + base::ProcessHandle child_process = + SpawnChild(L"process_watcher_test_die_immediately"); + // Give it time to die. + sleep(2); + ProcessWatcher::EnsureProcessTerminated(child_process); + + // Check that process was really killed. + EXPECT_TRUE(IsProcessDead(child_process)); + base::CloseProcessHandle(child_process); +} + +MULTIPROCESS_TEST_MAIN(process_watcher_test_die_immediately) { + return 0; +} + #endif // OS_POSIX |