blob: ce71cfc3fc857bd5cf1dfefdfa022666570874cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
--- base/process/process_info_linux.cc.orig 2017-04-19 19:06:28 UTC
+++ base/process/process_info_linux.cc
@@ -11,10 +11,28 @@
#include "base/process/process_handle.h"
#include "base/time/time.h"
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/user.h>
+#endif
+
namespace base {
// static
const Time CurrentProcessInfo::CreationTime() {
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, getpid() };
+ struct kinfo_proc proc;
+ size_t len = sizeof(struct kinfo_proc);
+ if (sysctl(mib, arraysize(mib), &proc, &len, NULL, 0) < 0)
+ return Time();
+#if defined(__DragonFly__)
+ return Time::FromTimeVal(proc.kp_start);
+#else
+ return Time::FromTimeVal(proc.ki_start);
+#endif
+#else
int64_t start_ticks =
internal::ReadProcSelfStatsAndGetFieldAsInt64(internal::VM_STARTTIME);
DCHECK(start_ticks);
@@ -22,6 +40,7 @@ const Time CurrentProcessInfo::CreationT
Time boot_time = internal::GetBootTime();
DCHECK(!boot_time.is_null());
return Time(boot_time + start_offset);
+#endif
}
} // namespace base
|