Skip to content

Commit

Permalink
Merge pull request #435 from mmcco/freebsd
Browse files Browse the repository at this point in the history
Improve error reporting on FreeBSD libkvm call
  • Loading branch information
hishamhm committed Mar 7, 2016
2 parents 63c5585 + b886ecc commit 4623394
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions freebsd/FreeBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

/*{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 4623394

Please sign in to comment.