Merge r46466 from the trunk to the 375 branch.
Kernel zombie death race!
Harden process_watcher_mac against zombie-admitting holes.
A race between the application and the kernel exists in that a process stops
being kqueueable before it becomes waitable. If
ProcessWatcher::EnsureProcessTerminated was called within this window, it
would assume that the process had already been reaped. The process would
then become waitable, but by then, the application forgot about it, and it
would be leaked as a zombie until the application as a whole was quit.
In order to kill the undead, this code now detects not-kqueueable not-waitable
processes and does a blocking wait, with a kill thrown in for good measure.
Other opportunities for this code to return early without making the best
effort to kill the process have been plugged up too. If any of the kqueue
operations fail, this will now fall through to kill and wait for the process.
TEST=A. Steps from bug 43150 comment 8:
1. Clean profile.
2. Launch. The home page, http://www.google.com/
, will load.
3. Type (or paste) about:blank into the omnibox.
Expect: no zombies.
Observe: original renderer process almost always becomes undead.
Note: Perform the test multiple times. It's timing-sensitive. I
experienced varying degrees of success reproducing zombies when
launching the app by double-clicking it, running it from a
terminal window with stdout and stderr on the terminal, and
running it from a terminal window with stdout and stderr
redirected to a file. With this fix, no zombies should be
B. zombies.py test from bug 43244.
Review URL: http://codereview.chromium.org/1915003