Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
HiGarfield committed Sep 29, 2024
1 parent b945070 commit 347ea20
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/process_iterator_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <kvm.h>
#include <sys/param.h>
#include <paths.h>
#include <string.h>

int init_process_iterator(struct process_iterator *it, struct process_filter *filter)
{
Expand All @@ -58,21 +59,12 @@ int init_process_iterator(struct process_iterator *it, struct process_filter *fi

static void kproc2proc(kvm_t *kd, struct kinfo_proc *kproc, struct process *proc)
{
char **args;
size_t len_max;
proc->pid = kproc->ki_pid;
proc->ppid = kproc->ki_ppid;
proc->cputime = kproc->ki_runtime / 1000.0;
len_max = sizeof(proc->command) - 1;
if ((args = kvm_getargv(kd, kproc, len_max)) != NULL)
{
strncpy(proc->command, args[0], len_max);
proc->command[len_max] = '\0';
}
else
{
proc->command[0] = '\0';
}
strncpy(proc->command, kproc->ki_comm, sizeof(proc->command) - 1);
proc->command[sizeof(proc->command) - 1] = '\0';
}

static int get_single_process(kvm_t *kd, pid_t pid, struct process *process)
Expand Down

0 comments on commit 347ea20

Please sign in to comment.