summaryrefslogtreecommitdiff
path: root/sysdeps/openbsd/shm_limits.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/openbsd/shm_limits.c')
-rw-r--r--sysdeps/openbsd/shm_limits.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sysdeps/openbsd/shm_limits.c b/sysdeps/openbsd/shm_limits.c
index 16fc5cf7..fb43756a 100644
--- a/sysdeps/openbsd/shm_limits.c
+++ b/sysdeps/openbsd/shm_limits.c
@@ -39,28 +39,33 @@ static unsigned long _glibtop_sysdeps_shm_limits =
* since `shminfo' is already declared external in <sys/shm.h>. */
static struct shminfo _shminfo;
-/* nlist structure for kernel access */
-static struct nlist nlst [] = {
- { "_shminfo" },
- { 0 }
-};
-
/* Init function. */
void
_glibtop_init_shm_limits_p (glibtop *server)
{
- if (kvm_nlist (server->machine->kd, nlst) < 0) {
- glibtop_warn_io_r (server, "kvm_nlist (shm_limits)");
+ int mib[3];
+ struct shm_sysctl_info *shmsi;
+ size_t len = sizeof(struct shminfo);
+
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_SYSVIPC_INFO;
+ mib[2] = KERN_SYSVIPC_SHM_INFO;
+
+ if ((shmsi = malloc(len)) == NULL) {
+ glibtop_warn_io_r (server, "malloc (shm_limits)");
return;
}
- if (kvm_read (server->machine->kd, nlst [0].n_value,
- &_shminfo, sizeof (_shminfo)) != sizeof (_shminfo)) {
- glibtop_warn_io_r (server, "kvm_read (shminfo)");
+ if (sysctl(mib, 3, shmsi, &len, NULL, 0) < 0) {
+ glibtop_warn_io_r (server, "sysctl (shm_limits)");
return;
}
+ _shminfo = shmsi->shminfo;
+
+ free (shmsi);
+
server->sysdeps.shm_limits = _glibtop_sysdeps_shm_limits;
}