summaryrefslogtreecommitdiffstats
path: root/darwin
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2021-05-25 19:03:54 +0200
committerBenny Baumann <BenBE@geshi.org>2021-05-25 21:55:04 +0200
commit06073699ba8728bb132763205d079ce44dd4f76d (patch)
tree341346181f8c33d9a1b93759ed224c67b5f72338 /darwin
parentb6ff5c8a2e5981a0e71423953b565a1389c5428d (diff)
Darwin: Implement CWD column
Diffstat (limited to 'darwin')
-rw-r--r--darwin/DarwinProcess.c25
-rw-r--r--darwin/ProcessField.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 7aaee110..96d10b0e 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -45,6 +45,8 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
[TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, .defaultSortDesc = true, },
[NLWP] = { .name = "NLWP", .title = "NLWP ", .description = "Number of threads in the process", .flags = 0, },
[TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
+ [PROC_EXE] = { .name = "EXE", .title = "EXE ", .description = "Basename of exe of the process from /proc/[pid]/exe", .flags = 0, },
+ [CWD] = { .name = "CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_CWD, },
[TRANSLATED] = { .name = "TRANSLATED", .title = "T ", .description = "Translation info (T translated, N native)", .flags = 0, },
};
@@ -106,6 +108,25 @@ static void DarwinProcess_updateExe(pid_t pid, Process* proc) {
Process_updateExe(proc, path);
}
+static void DarwinProcess_updateCwd(pid_t pid, Process* proc) {
+ struct proc_vnodepathinfo vpi;
+
+ int r = proc_pidinfo(pid, PROC_PIDVNODEPATHINFO, 0, &vpi, sizeof(vpi));
+ if (r <= 0) {
+ free(proc->procCwd);
+ proc->procCwd = NULL;
+ return;
+ }
+
+ if (!vpi.pvi_cdir.vip_path[0]) {
+ free(proc->procCwd);
+ proc->procCwd = NULL;
+ return;
+ }
+
+ free_and_xStrdup(&proc->procCwd, vpi.pvi_cdir.vip_path);
+}
+
static void DarwinProcess_updateCmdLine(const struct kinfo_proc* k, Process* proc) {
Process_updateComm(proc, k->kp_proc.p_comm);
@@ -294,6 +315,10 @@ void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps,
DarwinProcess_updateExe(ep->p_pid, proc);
DarwinProcess_updateCmdLine(ps, proc);
+
+ if (proc->settings->flags & PROCESS_FLAG_CWD) {
+ DarwinProcess_updateCwd(ep->p_pid, proc);
+ }
}
/* Mutable information */
diff --git a/darwin/ProcessField.h b/darwin/ProcessField.h
index 5a8090fe..25dbb450 100644
--- a/darwin/ProcessField.h
+++ b/darwin/ProcessField.h
@@ -10,6 +10,8 @@ in the source distribution for its full text.
#define PLATFORM_PROCESS_FIELDS \
TRANSLATED = 100, \
+ \
+ DUMMY_BUMP_FIELD = CWD, \
// End of list

© 2014-2024 Faster IT GmbH | imprint | privacy policy