mirror of https://github.com/xzeldon/htop.git
FreeBSD: Implement CWD column
This commit is contained in:
parent
c2e2556403
commit
90f42695d2
|
@ -46,6 +46,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
|||
[TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
|
||||
[PROC_COMM] = { .name = "COMM", .title = "COMM ", .description = "comm string of the process", .flags = 0, },
|
||||
[PROC_EXE] = { .name = "EXE", .title = "EXE ", .description = "Basename of exe of the process", .flags = 0, },
|
||||
[CWD] = { .name = "CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_CWD, },
|
||||
[JID] = { .name = "JID", .title = "JID", .description = "Jail prison ID", .flags = 0, .pidColumn = true, },
|
||||
[JAIL] = { .name = "JAIL", .title = "JAIL ", .description = "Jail prison name", .flags = 0, },
|
||||
};
|
||||
|
|
|
@ -395,6 +395,26 @@ static void FreeBSDProcessList_updateExe(const struct kinfo_proc* kproc, Process
|
|||
Process_updateExe(proc, buffer);
|
||||
}
|
||||
|
||||
static void FreeBSDProcessList_updateCwd(const struct kinfo_proc* kproc, Process* proc) {
|
||||
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_CWD, kproc->ki_pid };
|
||||
char buffer[2048];
|
||||
size_t size = sizeof(buffer);
|
||||
if (sysctl(mib, 4, buffer, &size, NULL, 0) != 0) {
|
||||
free(proc->procCwd);
|
||||
proc->procCwd = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Kernel threads return an empty buffer */
|
||||
if (buffer[0] == '\0') {
|
||||
free(proc->procCwd);
|
||||
proc->procCwd = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
free_and_xStrdup(&proc->procCwd, buffer);
|
||||
}
|
||||
|
||||
static void FreeBSDProcessList_updateProcessName(kvm_t* kd, const struct kinfo_proc* kproc, Process* proc) {
|
||||
Process_updateComm(proc, kproc->ki_comm);
|
||||
|
||||
|
@ -495,6 +515,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
|
|||
FreeBSDProcessList_updateExe(kproc, proc);
|
||||
FreeBSDProcessList_updateProcessName(fpl->kd, kproc, proc);
|
||||
|
||||
if (settings->flags & PROCESS_FLAG_CWD) {
|
||||
FreeBSDProcessList_updateCwd(kproc, proc);
|
||||
}
|
||||
|
||||
fp->jname = FreeBSDProcessList_readJailName(kproc);
|
||||
|
||||
proc->tty_nr = kproc->ki_tdev;
|
||||
|
|
|
@ -12,7 +12,7 @@ in the source distribution for its full text.
|
|||
JID = 100, \
|
||||
JAIL = 101, \
|
||||
\
|
||||
DUMMY_BUMP_FIELD = PROC_EXE, \
|
||||
DUMMY_BUMP_FIELD = CWD, \
|
||||
// End of list
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue