Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
HiGarfield committed Sep 28, 2024
1 parent b9cc8bb commit 01f1cee
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/process_iterator_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,18 @@ 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;
int nread;
proc->pid = kproc->ki_pid;
proc->ppid = kproc->ki_ppid;
proc->cputime = kproc->ki_runtime / 1000;
proc->starttime = kproc->ki_start.tv_sec;
len_max = sizeof(proc->command);
if ((args = kvm_getargv(kd, kproc, len_max)) != NULL)
nread = kvm_read(kd, (u_long)kproc[0].ki_comm, proc->command, MAXPATHLEN);
if (nread < 0)
{
strncpy(proc->command, args[0], len_max);
proc->command[len_max] = '\0';
proc->command[0] = '\0';
}
else
{
proc->command[0] = '\0';
proc->command[nread] = '\0';
}
}

Expand Down

0 comments on commit 01f1cee

Please sign in to comment.