From 4d7cee56f04c7c716ad8289047b8d1cb44c4c4fe Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Thu, 15 Apr 2021 09:03:12 +1000 Subject: Rework TTY column for the PCP platform --- pcp/PCPProcess.c | 10 +--------- pcp/PCPProcess.h | 1 - pcp/PCPProcessList.c | 6 +++--- 3 files changed, 4 insertions(+), 13 deletions(-) (limited to 'pcp') diff --git a/pcp/PCPProcess.c b/pcp/PCPProcess.c index 7e8f59ae..4a5cdb32 100644 --- a/pcp/PCPProcess.c +++ b/pcp/PCPProcess.c @@ -32,7 +32,7 @@ const ProcessFieldData Process_fields[] = { [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, }, - [TTY_NR] = { .name = "TTY_NR", .title = "TTY ", .description = "Controlling terminal", .flags = 0, }, + [TTY] = { .name = "TTY", .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, }, [MINFLT] = { .name = "MINFLT", .title = " MINFLT ", .description = "Number of minor faults which have not required loading a memory page from disk", .flags = 0, .defaultSortDesc = true, }, [CMINFLT] = { .name = "CMINFLT", .title = " CMINFLT ", .description = "Children processes' minor faults", .flags = 0, .defaultSortDesc = true, }, @@ -107,7 +107,6 @@ void Process_delete(Object* cast) { Process_done((Process*)cast); free(this->cgroup); free(this->secattr); - free(this->ttyDevice); free(this->procComm); free(this->mergedCommand.str); free(this); @@ -332,13 +331,6 @@ static void PCPProcess_writeField(const Process* this, RichString* str, ProcessF int attr = CRT_colors[DEFAULT_COLOR]; int n = sizeof(buffer) - 1; switch ((int)field) { - case TTY_NR: - if (pp->ttyDevice) { - xSnprintf(buffer, n, "%-8s", pp->ttyDevice + 5 /* skip "/dev/" */); - break; - } - Process_writeField(this, str, field); - break; case CMINFLT: Process_colorNumber(str, pp->cminflt, coloring); return; case CMAJFLT: Process_colorNumber(str, pp->cmajflt, coloring); return; case M_DRS: Process_humanNumber(str, pp->m_drs, coloring); return; diff --git a/pcp/PCPProcess.h b/pcp/PCPProcess.h index d3d1abe0..946d3831 100644 --- a/pcp/PCPProcess.h +++ b/pcp/PCPProcess.h @@ -98,7 +98,6 @@ typedef struct PCPProcess_ { double io_rate_write_bps; char* cgroup; unsigned int oom; - char* ttyDevice; unsigned long long int delay_read_time; unsigned long long cpu_delay_total; unsigned long long blkio_delay_total; diff --git a/pcp/PCPProcessList.c b/pcp/PCPProcessList.c index 847765a2..3755c9bc 100644 --- a/pcp/PCPProcessList.c +++ b/pcp/PCPProcessList.c @@ -352,8 +352,8 @@ static char* setString(Metric metric, int pid, int offset, char* string) { return string; } -static void PCPProcessList_updateTTY(PCPProcess* process, int pid, int offset) { - process->ttyDevice = setString(PCP_PROC_TTYNAME, pid, offset, process->ttyDevice); +static void PCPProcessList_updateTTY(Process* process, int pid, int offset) { + process->tty_name = setString(PCP_PROC_TTYNAME, pid, offset, process->tty_name); } static void PCPProcessList_readCGroups(PCPProcess* process, int pid, int offset) { @@ -495,7 +495,7 @@ static bool PCPProcessList_updateProcesses(PCPProcessList* this, double period, PCPProcessList_updateInfo(proc, pid, offset, command, sizeof(command)); proc->starttime_ctime += Platform_getBootTime(); if (tty_nr != proc->tty_nr) - PCPProcessList_updateTTY(pp, pid, offset); + PCPProcessList_updateTTY(proc, pid, offset); float percent_cpu = (pp->utime + pp->stime - lasttimes) / period * 100.0; proc->percent_cpu = isnan(percent_cpu) ? -- cgit v1.2.3