mirror of https://github.com/xzeldon/htop.git
Solaris: Implement CWD column
This commit is contained in:
parent
5e92956abc
commit
8420df62eb
|
@ -17,7 +17,7 @@ in the source distribution for its full text.
|
||||||
CONTID = 105, \
|
CONTID = 105, \
|
||||||
LWPID = 106, \
|
LWPID = 106, \
|
||||||
\
|
\
|
||||||
DUMMY_BUMP_FIELD = PROC_EXE, \
|
DUMMY_BUMP_FIELD = CWD, \
|
||||||
// End of list
|
// End of list
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||||
[TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
|
[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_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, },
|
[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, },
|
||||||
[ZONEID] = { .name = "ZONEID", .title = "ZONEID", .description = "Zone ID", .flags = 0, .pidColumn = true, },
|
[ZONEID] = { .name = "ZONEID", .title = "ZONEID", .description = "Zone ID", .flags = 0, .pidColumn = true, },
|
||||||
[ZONE] = { .name = "ZONE", .title = "ZONE ", .description = "Zone name", .flags = 0, },
|
[ZONE] = { .name = "ZONE", .title = "ZONE ", .description = "Zone name", .flags = 0, },
|
||||||
[PROJID] = { .name = "PROJID", .title = "PRJID", .description = "Project ID", .flags = 0, .pidColumn = true, },
|
[PROJID] = { .name = "PROJID", .title = "PRJID", .description = "Project ID", .flags = 0, .pidColumn = true, },
|
||||||
|
|
|
@ -309,6 +309,19 @@ static void SolarisProcessList_updateExe(pid_t pid, Process* proc) {
|
||||||
Process_updateExe(proc, target);
|
Process_updateExe(proc, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SolarisProcessList_updateCwd(pid_t pid, Process* proc) {
|
||||||
|
char path[32];
|
||||||
|
xSnprintf(path, sizeof(path), "/proc/%d/cwd", pid);
|
||||||
|
|
||||||
|
char target[PATH_MAX];
|
||||||
|
ssize_t ret = readlink(path, target, sizeof(target) - 1);
|
||||||
|
if (ret <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
target[ret] = '\0';
|
||||||
|
free_and_xStrdup(&proc->procCwd, target);
|
||||||
|
}
|
||||||
|
|
||||||
/* NOTE: the following is a callback function of type proc_walk_f
|
/* NOTE: the following is a callback function of type proc_walk_f
|
||||||
* and MUST conform to the appropriate definition in order
|
* and MUST conform to the appropriate definition in order
|
||||||
* to work. See libproc(3LIB) on a Solaris or Illumos
|
* to work. See libproc(3LIB) on a Solaris or Illumos
|
||||||
|
@ -377,8 +390,13 @@ static int SolarisProcessList_walkproc(psinfo_t* _psinfo, lwpsinfo_t* _lwpsinfo,
|
||||||
sproc->zname = SolarisProcessList_readZoneName(spl->kd, sproc);
|
sproc->zname = SolarisProcessList_readZoneName(spl->kd, sproc);
|
||||||
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
|
proc->user = UsersTable_getRef(pl->usersTable, proc->st_uid);
|
||||||
SolarisProcessList_updateExe(_psinfo->pr_pid, proc);
|
SolarisProcessList_updateExe(_psinfo->pr_pid, proc);
|
||||||
|
|
||||||
Process_updateComm(proc, _psinfo->pr_fname);
|
Process_updateComm(proc, _psinfo->pr_fname);
|
||||||
Process_updateCmdline(proc, _psinfo->pr_psargs, 0, 0);
|
Process_updateCmdline(proc, _psinfo->pr_psargs, 0, 0);
|
||||||
|
|
||||||
|
if (proc->settings->flags & PROCESS_FLAG_CWD) {
|
||||||
|
SolarisProcessList_updateCwd(_psinfo->pr_pid, proc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End common code pass 1
|
// End common code pass 1
|
||||||
|
|
Loading…
Reference in New Issue