openbsd-ports/www/chromium/patches/patch-base_process_util_openbsd_cc
2011-12-14 16:58:19 +00:00

28 lines
1001 B
Plaintext

$OpenBSD: patch-base_process_util_openbsd_cc,v 1.7 2011/12/14 16:58:19 robert Exp $
--- base/process_util_openbsd.cc.orig Wed Dec 7 09:01:59 2011
+++ base/process_util_openbsd.cc Tue Dec 13 22:11:09 2011
@@ -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)