summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-19 01:03:48 +0100
committerinfirit <[email protected]>2014-12-19 01:03:48 +0100
commitf6930d670aeb0a4c981e4d49221494c53da27d49 (patch)
tree4bb72226b8808583eb83928a402cc4a5f37c6a0e /src
parent9054799f2fbdf17dfc5ffad0be1d3f96548c5a13 (diff)
downloadmate-system-monitor-f6930d670aeb0a4c981e4d49221494c53da27d49.tar.bz2
mate-system-monitor-f6930d670aeb0a4c981e4d49221494c53da27d49.tar.xz
procproperties: unbreak on OpenBSD
The asm/param.h header is only found on Linux. On OpenBSD, the HZ tick is not defined in any header but can be retrieved from the running kernel using the sysctl(3) interface. Taken from GSM commit: 94be681c159b56ad42afb13c3e18d59be4422558 From: Antoine Jacoutot <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/procproperties.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/procproperties.cpp b/src/procproperties.cpp
index 0020782..b378dc6 100644
--- a/src/procproperties.cpp
+++ b/src/procproperties.cpp
@@ -24,7 +24,12 @@
#include <glibtop/procmem.h>
#include <glibtop/procmap.h>
#include <glibtop/procstate.h>
+#if defined (__linux__)
#include <asm/param.h>
+#elif defined (__OpenBSD__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#endif
#include "procman.h"
#include "procproperties.h"
@@ -109,6 +114,18 @@ fill_proc_properties (GtkWidget *tree, ProcInfo *info)
get_process_memory_info(info);
+#if defined (__OpenBSD__)
+ struct clockinfo cinf;
+ size_t size = sizeof (cinf);
+ int HZ;
+ int mib[] = { CTL_KERN, KERN_CLOCKRATE };
+
+ if (sysctl (mib, nitems(mib), &cinf, &size, NULL, 0) == -1)
+ HZ = 100;
+ else
+ HZ = cinf.hz;
+#endif
+
proc_arg proc_props[] = {
{ N_("Process Name"), g_strdup_printf("%s", info->name)},
{ N_("User"), g_strdup_printf("%s (%d)", info->user.c_str(), info->uid)},