mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-24 15:15:44 +00:00
NetBSD: fix reading environment variables of processes
kvm_getenvv(3) seems not to work with kvm_openfiles(..., KVM_NO_FILES, ...)
This commit is contained in:
parent
7f95ed8528
commit
fd2c4f5ddd
@ -281,19 +281,19 @@ char* Platform_getProcessEnv(pid_t pid) {
|
||||
char** ptr;
|
||||
int count;
|
||||
kvm_t* kt;
|
||||
struct kinfo_proc* kproc;
|
||||
const struct kinfo_proc2* kproc;
|
||||
size_t capacity = 4096, size = 0;
|
||||
|
||||
if ((kt = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((kproc = kvm_getprocs(kt, KERN_PROC_PID, pid, &count)) == NULL) {
|
||||
if ((kproc = kvm_getproc2(kt, KERN_PROC_PID, pid, sizeof(struct kinfo_proc2), &count)) == NULL) {
|
||||
(void) kvm_close(kt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ptr = kvm_getenvv(kt, kproc, 0)) == NULL) {
|
||||
if ((ptr = kvm_getenvv2(kt, kproc, 0)) == NULL) {
|
||||
(void) kvm_close(kt);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user