mirror of
https://github.com/xzeldon/htop.git
synced 2025-07-12 04:04:35 +03:00
Merge Process_pidColumns into Process_fields and rework auto-fit for PID-like columns
This commit is contained in:

committed by
cgzones

parent
89473cc9ae
commit
9f68c8d341
@ -30,16 +30,16 @@ int pageSizeKB;
|
||||
/* Used to identify kernel threads in Comm and Exe columns */
|
||||
static const char *const kthreadID = "KTHREAD";
|
||||
|
||||
ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = " PID ", .description = "Process/thread ID", .flags = 0, },
|
||||
[PID] = { .name = "PID", .title = "PID", .description = "Process/thread ID", .flags = 0, .pidColumn = true, },
|
||||
[COMM] = { .name = "Command", .title = "Command ", .description = "Command line", .flags = 0, },
|
||||
[STATE] = { .name = "STATE", .title = "S ", .description = "Process state (S sleeping, R running, D disk, Z zombie, T traced, W paging, I idle)", .flags = 0, },
|
||||
[PPID] = { .name = "PPID", .title = " PPID ", .description = "Parent process ID", .flags = 0, },
|
||||
[PGRP] = { .name = "PGRP", .title = " PGRP ", .description = "Process group ID", .flags = 0, },
|
||||
[SESSION] = { .name = "SESSION", .title = " SID ", .description = "Process's session ID", .flags = 0, },
|
||||
[PPID] = { .name = "PPID", .title = "PPID", .description = "Parent process ID", .flags = 0, .pidColumn = true, },
|
||||
[PGRP] = { .name = "PGRP", .title = "PGRP", .description = "Process group ID", .flags = 0, .pidColumn = true, },
|
||||
[SESSION] = { .name = "SESSION", .title = "SID", .description = "Process's session ID", .flags = 0, .pidColumn = true, },
|
||||
[TTY_NR] = { .name = "TTY_NR", .title = "TTY ", .description = "Controlling terminal", .flags = 0, },
|
||||
[TPGID] = { .name = "TPGID", .title = " TPGID ", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, },
|
||||
[TPGID] = { .name = "TPGID", .title = "TPGID", .description = "Process ID of the fg process group of the controlling terminal", .flags = 0, .pidColumn = true, },
|
||||
[MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, },
|
||||
[CMINFLT] = { .name = "CMINFLT", .title = " CMINFLT ", .description = "Children processes' minor faults", .flags = 0, },
|
||||
[MAJFLT] = { .name = "MAJFLT", .title = " MAJFLT ", .description = "Number of major faults which have required loading a memory page from disk", .flags = 0, },
|
||||
@ -66,10 +66,10 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[USER] = { .name = "USER", .title = "USER ", .description = "Username of the process owner (or user ID if name cannot be determined)", .flags = 0, },
|
||||
[TIME] = { .name = "TIME", .title = " TIME+ ", .description = "Total time the process has spent in user and system time", .flags = 0, },
|
||||
[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, },
|
||||
[TGID] = { .name = "TGID", .title = "TGID", .description = "Thread group ID (i.e. process ID)", .flags = 0, .pidColumn = true, },
|
||||
#ifdef HAVE_OPENVZ
|
||||
[CTID] = { .name = "CTID", .title = " CTID ", .description = "OpenVZ container ID (a.k.a. virtual environment ID)", .flags = PROCESS_FLAG_LINUX_OPENVZ, },
|
||||
[VPID] = { .name = "VPID", .title = " VPID ", .description = "OpenVZ process ID", .flags = PROCESS_FLAG_LINUX_OPENVZ, },
|
||||
[VPID] = { .name = "VPID", .title = "VPID", .description = "OpenVZ process ID", .flags = PROCESS_FLAG_LINUX_OPENVZ, .pidColumn = true, },
|
||||
#endif
|
||||
#ifdef HAVE_VSERVER
|
||||
[VXID] = { .name = "VXID", .title = " VXID ", .description = "VServer process ID", .flags = PROCESS_FLAG_LINUX_VSERVER, },
|
||||
@ -102,19 +102,6 @@ ProcessFieldData Process_fields[LAST_PROCESSFIELD] = {
|
||||
[CWD] = { .name ="CWD", .title = "CWD ", .description = "The current working directory of the process", .flags = PROCESS_FLAG_LINUX_CWD, },
|
||||
};
|
||||
|
||||
ProcessPidColumn Process_pidColumns[] = {
|
||||
{ .id = PID, .label = "PID" },
|
||||
{ .id = PPID, .label = "PPID" },
|
||||
#ifdef HAVE_OPENVZ
|
||||
{ .id = VPID, .label = "VPID" },
|
||||
#endif
|
||||
{ .id = TPGID, .label = "TPGID" },
|
||||
{ .id = TGID, .label = "TGID" },
|
||||
{ .id = PGRP, .label = "PGRP" },
|
||||
{ .id = SESSION, .label = "SID" },
|
||||
{ .id = 0, .label = NULL },
|
||||
};
|
||||
|
||||
/* This function returns the string displayed in Command column, so that sorting
|
||||
* happens on what is displayed - whether comm, full path, basename, etc.. So
|
||||
* this follows LinuxProcess_writeField(COMM) and LinuxProcess_writeCommand */
|
||||
@ -662,7 +649,7 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces
|
||||
}
|
||||
#ifdef HAVE_OPENVZ
|
||||
case CTID: xSnprintf(buffer, n, "%-8s ", lp->ctid ? lp->ctid : ""); break;
|
||||
case VPID: xSnprintf(buffer, n, Process_pidFormat, lp->vpid); break;
|
||||
case VPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, lp->vpid); break;
|
||||
#endif
|
||||
#ifdef HAVE_VSERVER
|
||||
case VXID: xSnprintf(buffer, n, "%5u ", lp->vxid); break;
|
||||
|
Reference in New Issue
Block a user