Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1164)

Unified Diff: chrome/test/test_launcher/out_of_proc_test_runner.cc

Issue 3423012: Cleanup orphaned testserver processes on posix. (Closed)
Patch Set: CR feedback. Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process_util_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/test_launcher/out_of_proc_test_runner.cc
diff --git a/chrome/test/test_launcher/out_of_proc_test_runner.cc b/chrome/test/test_launcher/out_of_proc_test_runner.cc
index 47be495b7f48e5aea54ff94d8117727842cfa697..282ae4a777906061477e4791b34b637654671bec 100644
--- a/chrome/test/test_launcher/out_of_proc_test_runner.cc
+++ b/chrome/test/test_launcher/out_of_proc_test_runner.cc
@@ -89,7 +89,18 @@ class OutOfProcTestRunner : public tests::TestRunner {
new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling);
base::ProcessHandle process_handle;
+#if defined(OS_POSIX)
+ // On POSIX, we launch the test in a new process group with pgid equal to
+ // its pid. Any child processes that the test may create will inherit the
+ // same pgid. This way, if the test is abruptly terminated, we can clean up
+ // any orphaned child processes it may have left behind.
+ base::environment_vector no_env;
+ base::file_handle_mapping_vector no_files;
+ if (!base::LaunchAppInNewProcessGroup(new_cmd_line.argv(), no_env, no_files,
+ false, &process_handle))
+#else
if (!base::LaunchApp(new_cmd_line, false, false, &process_handle))
+#endif
return false;
int test_terminate_timeout_ms = kDefaultTestTimeoutMs;
@@ -111,6 +122,13 @@ class OutOfProcTestRunner : public tests::TestRunner {
// Ensure that the process terminates.
base::KillProcess(process_handle, -1, true);
+
+#if defined(OS_POSIX)
+ // On POSIX, we need to clean up any child processes that the test might
+ // have created. On windows, child processes are automatically cleaned up
+ // using JobObjects.
+ base::KillProcessGroup(process_handle);
+#endif
}
return exit_code == 0;
« no previous file with comments | « base/process_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698