diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2016-03-07 16:35:59 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2016-03-07 16:35:59 -0300 |
commit | 462339445696126b7e17f97342a559dbbd750cac (patch) | |
tree | 2fffd82a7537437452d731038970cbccda0f84c1 | |
parent | 63c55854e59250f44006445b24bf6168064e2426 (diff) | |
parent | b886ecc4795723d4b596a03c3e2a88cc2dc191ba (diff) |
Merge pull request #435 from mmcco/freebsd
Improve error reporting on FreeBSD libkvm call
-rw-r--r-- | freebsd/FreeBSDProcessList.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/freebsd/FreeBSDProcessList.c b/freebsd/FreeBSDProcessList.c index ebb07620..0cfe16c3 100644 --- a/freebsd/FreeBSDProcessList.c +++ b/freebsd/FreeBSDProcessList.c @@ -14,7 +14,9 @@ in the source distribution for its full text. #include <sys/types.h> #include <sys/sysctl.h> #include <sys/user.h> +#include <err.h> #include <fcntl.h> +#include <limits.h> #include <string.h> /*{ @@ -86,12 +88,12 @@ static int kernelFScale; ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId) { + size_t len; + char errbuf[_POSIX2_LINE_MAX]; FreeBSDProcessList* fpl = xCalloc(1, sizeof(FreeBSDProcessList)); ProcessList* pl = (ProcessList*) fpl; ProcessList_init(pl, Class(FreeBSDProcess), usersTable, pidWhiteList, userId); - size_t len; - // physical memory in system: hw.physmem // physical page size: hw.pagesize // usable pagesize : vm.stats.vm.v_page_size @@ -178,8 +180,10 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui kernelFScale = 2048; } - fpl->kd = kvm_open(NULL, "/dev/null", NULL, 0, NULL); - assert(fpl->kd); + fpl->kd = kvm_openfiles(NULL, "/dev/null", NULL, 0, errbuf); + if (fpl->kd == NULL) { + errx(1, "kvm_open: %s", errbuf); + } return pl; } |