test::Multiprocess: exit cleanly from children with _exit().

Child exits were using exit(), which caused crashes on 10.10 for
Multiprocess-based tests that ran after HTTPTransport tests. The crashes
occurred while running exit-time destructors. exit() was never correct
in this situation, this should have used _exit() all along.

TEST=crashpad_util_test
BUG=crashpad:17
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1000653002
This commit is contained in:
Mark Mentovai 2015-03-11 13:59:46 -04:00
parent b8d2129bc1
commit b8cbfff0d3
2 changed files with 10 additions and 4 deletions

View File

@ -164,9 +164,9 @@ class Multiprocess {
//! \brief Runs the child side of the test.
//!
//! This method establishes the childs environment, calls
//! MultiprocessChild(), and exits cleanly. However, if any failure (via fatal
//! or nonfatal gtest assertion) is detected, the child will exit with a
//! failure status.
//! MultiprocessChild(), and exits cleanly by calling `_exit(0)`. However, if
//! any failure (via fatal or nonfatal gtest assertion) is detected, the child
//! will exit with a failure status.
void RunChild();
//! \brief The subclass-provided parent routine.
@ -186,6 +186,11 @@ class Multiprocess {
//! `FAIL()`, etc.
//!
//! Subclasses must implement this method to define how the child operates.
//! Subclasses may exit with a failure status by using `LOG(FATAL)`,
//! `abort()`, or similar. They may exit cleanly by returning from this method
//! or by calling `_exit(0)`. Under no circumstances may `exit()` be called
//! by the child without having the child process `exec()`. Use
//! MultiprocessExec if the child should call `exec()`.
virtual void MultiprocessChild() = 0;
internal::MultiprocessInfo* info_;

View File

@ -212,7 +212,8 @@ void Multiprocess::RunChild() {
return;
}
exit(0);
// In a forked child, exit() is unsafe. Use _exit() instead.
_exit(EXIT_SUCCESS);
}
} // namespace test