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

Unified Diff: base/process_util_openbsd.cc

Issue 8390002: implement GetProcessExecutablePath() on OpenBSD and start using it (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: return the variable instead Created 9 years, 2 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.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_openbsd.cc
diff --git a/base/process_util_openbsd.cc b/base/process_util_openbsd.cc
index b442e9326cd80c5fb21eaec88e024009dbd7f020..67c901fa53e3e80af7fbceeb2fe46647793272d0 100644
--- a/base/process_util_openbsd.cc
+++ b/base/process_util_openbsd.cc
@@ -47,7 +47,22 @@ ProcessId GetParentProcessId(ProcessHandle process) {
}
FilePath GetProcessExecutablePath(ProcessHandle process) {
- return FilePath(std::string("/usr/local/chrome/chrome"));
+ struct kinfo_proc kp;
+ size_t len;
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, process,
+ sizeof(struct kinfo_proc), 0 };
+
+ if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) == -1)
+ return FilePath();
+ mib[5] = (len / sizeof(struct kinfo_proc));
+ if (sysctl(mib, arraysize(mib), &kp, &len, NULL, 0) < 0)
+ return FilePath();
+ if ((kp.p_flag & P_SYSTEM) != 0)
+ return FilePath();
+ if (strcmp(kp.p_comm, "chrome") == 0)
+ return FilePath(kp.p_comm);
+
+ return FilePath();
}
ProcessIterator::ProcessIterator(const ProcessFilter* filter)
« no previous file with comments | « base/process_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698