summaryrefslogtreecommitdiffstats
path: root/base/process_util_mac.mm
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 23:41:04 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 23:41:04 +0000
commitc47d81dedaf59d3441acdc0cd60fdddc7078aa2d (patch)
treea9b24dddc91774e3ce9ef212807a5fb406d1b295 /base/process_util_mac.mm
parent23f5ee3f8b0c9f854c080db48b1f97603576d865 (diff)
downloadchromium_src-c47d81dedaf59d3441acdc0cd60fdddc7078aa2d.zip
chromium_src-c47d81dedaf59d3441acdc0cd60fdddc7078aa2d.tar.gz
chromium_src-c47d81dedaf59d3441acdc0cd60fdddc7078aa2d.tar.bz2
Clean up orphaned testserver processes before launching a new one in net::TestServer
Several chrome tests have failed in recent days because some test cases crashed due to failures, leaving behind orphaned testserver processes. These test suites do not use out_of_proc_test_runner, and therefore, do not get the benefit of using the LaunchAppInNewProcessGroup()/KillProcessGroup() mechanism. This patch implements an added layer of safety, by causing TestServer::LaunchPython() to first kill any remaining orphaned instances of testserver.py before launching a new one. The check for an orphaned testserver process on POSIX is a process with exe_name "python", a parent_pid of "1" (indicating that it's an orphan), and command line parameters that contain the strings "testserver.py" and "<port>" where <port> is the port that is being used by the test server instance. BUG=55808,57253 TEST=Run a test that spawns a testserver and dies. Run another test. It shouldn't fail. Review URL: http://codereview.chromium.org/3537002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61584 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_mac.mm')
-rw-r--r--base/process_util_mac.mm15
1 files changed, 12 insertions, 3 deletions
diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm
index 2ea59a0..0865360 100644
--- a/base/process_util_mac.mm
+++ b/base/process_util_mac.mm
@@ -129,14 +129,23 @@ bool ProcessIterator::CheckForNextProcess() {
continue;
}
- // Data starts w/ the full path null termed, so we have to extract just the
- // executable name from the path.
-
+ // |data| contains all the command line parameters of the process, separated
+ // by blocks of one or more null characters. We tokenize |data| into a
+ // vector of strings using '\0' as a delimiter and populate
+ // |entry_.cmd_line_args_|.
+ std::string delimiters;
+ delimiters.push_back('\0');
+ Tokenize(data, delimiters, &entry_.cmd_line_args_);
+
+ // |data| starts with the full executable path followed by a null character.
+ // We search for the first instance of '\0' and extract everything before it
+ // to populate |entry_.exe_file_|.
size_t exec_name_end = data.find('\0');
if (exec_name_end == std::string::npos) {
LOG(ERROR) << "command line data didn't match expected format";
continue;
}
+
entry_.pid_ = kinfo.kp_proc.p_pid;
entry_.ppid_ = kinfo.kp_eproc.e_ppid;
entry_.gid_ = kinfo.kp_eproc.e_pgid;