$OpenBSD: patch-src_3rdparty_chromium_base_process_process_posix_cc,v 1.4 2021/01/19 06:16:33 rsadowski Exp $

Index: src/3rdparty/chromium/base/process/process_posix.cc
--- src/3rdparty/chromium/base/process/process_posix.cc.orig
+++ src/3rdparty/chromium/base/process/process_posix.cc
@@ -23,6 +23,11 @@
 #include <sys/event.h>
 #endif
 
+#if defined(OS_BSD)
+#include <sys/types.h>
+#include <sys/sysctl.h> 
+#endif
+
 #if BUILDFLAG(CLANG_PROFILING)
 #include "base/test/clang_profiling.h"
 #endif
@@ -380,7 +385,38 @@ bool Process::SetProcessBackgrounded(bool value) {
 
 int Process::GetPriority() const {
   DCHECK(IsValid());
+// avoid pledge(2) violation
+#if defined(OS_BSD)
+  return 0;
+#else
   return getpriority(PRIO_PROCESS, process_);
+#endif
+}
+
+Time Process::CreationTime() const {
+  int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid(),
+               sizeof(struct kinfo_proc), 0 };
+  struct kinfo_proc *info = nullptr;
+  size_t info_size;
+  Time ct = Time();
+
+  if (sysctl(mib, base::size(mib), NULL, &info_size, NULL, 0) < 0)
+    goto out;
+
+  mib[5] = (info_size / sizeof(struct kinfo_proc));
+  if ((info = reinterpret_cast<kinfo_proc*>(malloc(info_size))) == NULL)
+    goto out;
+
+  if (sysctl(mib, base::size(mib), info, &info_size, NULL, 0) < 0)
+    goto out;
+
+  ct = Time::FromTimeT(info->p_ustart_sec);
+
+out:
+  if (info)
+    free(info);
+
+  return ct;
 }
 
 }  // namespace base
