summaryrefslogtreecommitdiffstats
path: root/base/process_util_linux.cc
diff options
context:
space:
mode:
authordkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 23:29:11 +0000
committerdkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 23:29:11 +0000
commit78c6dd65953307dd0b550a16d92267a450c01309 (patch)
tree41fbb424f0285933d7fddd1d06d24b0b3a1a349b /base/process_util_linux.cc
parent37cd3a96b55aac1dad9016c05e78b5983972f985 (diff)
downloadchromium_src-78c6dd65953307dd0b550a16d92267a450c01309.zip
chromium_src-78c6dd65953307dd0b550a16d92267a450c01309.tar.gz
chromium_src-78c6dd65953307dd0b550a16d92267a450c01309.tar.bz2
Enable zygote manager by default.
Fix broken recursion check. Make OpenFile warning less scary, indicate it's normal at start of ui tests. Make ui tests pass. Avoid generating extra code on Mac. BUG=11841 TEST=start the browser, then make chrome and all .pak files unreadable; or alternately, start an installed browser, and uninstall the browser while it's running. Then create a new tab and browse to two new sites. Review URL: http://codereview.chromium.org/119289 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_linux.cc')
-rw-r--r--base/process_util_linux.cc46
1 files changed, 45 insertions, 1 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc
index 78725cc..ba2d8cd 100644
--- a/base/process_util_linux.cc
+++ b/base/process_util_linux.cc
@@ -7,10 +7,10 @@
#include <ctype.h>
#include <dirent.h>
#include <fcntl.h>
-#include <unistd.h>
#include <string>
#include <sys/types.h>
#include <sys/wait.h>
+#include <unistd.h>
#include "base/eintr_wrapper.h"
#include "base/file_util.h"
@@ -42,6 +42,50 @@ void GetProcStats(pid_t pid, std::vector<std::string>* proc_stats) {
namespace base {
+ProcessId GetParentProcessId(ProcessHandle process) {
+ FilePath stat_file("/proc");
+ stat_file = stat_file.Append(IntToString(process));
+ stat_file = stat_file.Append("status");
+ std::string status;
+ if (!file_util::ReadFileToString(stat_file, &status))
+ return -1;
+
+ StringTokenizer tokenizer(status, ":\n");
+ ParsingState state = KEY_NAME;
+ std::string last_key_name;
+ while (tokenizer.GetNext()) {
+ switch (state) {
+ case KEY_NAME:
+ last_key_name = tokenizer.token();
+ state = KEY_VALUE;
+ break;
+ case KEY_VALUE:
+ DCHECK(!last_key_name.empty());
+ if (last_key_name == "PPid") {
+ pid_t ppid = StringToInt(tokenizer.token());
+ return ppid;
+ }
+ state = KEY_NAME;
+ break;
+ }
+ }
+ NOTREACHED();
+ return -1;
+}
+
+FilePath GetProcessExecutablePath(ProcessHandle process) {
+ FilePath stat_file("/proc");
+ stat_file = stat_file.Append(IntToString(process));
+ stat_file = stat_file.Append("exe");
+ char exename[2048];
+ ssize_t len = readlink(stat_file.value().c_str(), exename, sizeof(exename));
+ if (len < 1) {
+ // No such process. Happens frequently in e.g. TerminateAllChromeProcesses
+ return FilePath();
+ }
+ return FilePath(std::string(exename, len));
+}
+
bool ForkApp(const std::vector<std::string>& argv,
const file_handle_mapping_vector& fds_to_remap,
ProcessHandle* process_handle) {