diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-03-21 19:40:56 +0100 |
---|---|---|
committer | cgzones <cgzones@googlemail.com> | 2021-04-14 17:29:56 +0200 |
commit | 9a8221568ada269d20c3e9d291ad5f9d07cac755 (patch) | |
tree | 025f098f3e98e3ae27105feb60dc76d4ff627452 /linux | |
parent | 36880cd61c52f13c6fd284aa23d42d9493d3ab2e (diff) |
Rework TTY column
* Rename internal identifier from TTY_NR to just TTY
* Unify column header on platforms
* Use devname(3) on BSD derivate to show the actual terminal,
simplifies current FreeBSD implementation.
* Use 'unsigned long int' as id type, to fit dev_t on Linux.
Only on Solaris the terminal path is not yet resolved.
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LinuxProcess.c | 11 | ||||
-rw-r--r-- | linux/LinuxProcess.h | 1 | ||||
-rw-r--r-- | linux/LinuxProcessList.c | 8 |
3 files changed, 5 insertions, 15 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index 764f0151..61f22349 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -38,7 +38,7 @@ const ProcessFieldData Process_fields[LAST_PROCESSFIELD] = { [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, }, + [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, .pidColumn = true, }, [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, }, @@ -129,7 +129,6 @@ void Process_delete(Object* cast) { #endif free(this->cwd); free(this->secattr); - free(this->ttyDevice); free(this->procExe); free(this->procComm); free(this->mergedCommand.str); @@ -610,14 +609,6 @@ static void LinuxProcess_writeField(const Process* this, RichString* str, Proces int attr = CRT_colors[DEFAULT_COLOR]; size_t n = sizeof(buffer) - 1; switch (field) { - case TTY_NR: - if (lp->ttyDevice) { - xSnprintf(buffer, n, "%-8s ", lp->ttyDevice + 5 /* skip "/dev/" */); - break; - } - - Process_writeField(this, str, field); - return; case CMINFLT: Process_colorNumber(str, lp->cminflt, coloring); return; case CMAJFLT: Process_colorNumber(str, lp->cmajflt, coloring); return; case M_DRS: Process_humanNumber(str, lp->m_drs * pageSizeKB, coloring); return; diff --git a/linux/LinuxProcess.h b/linux/LinuxProcess.h index 29ef2a98..622189b2 100644 --- a/linux/LinuxProcess.h +++ b/linux/LinuxProcess.h @@ -117,7 +117,6 @@ typedef struct LinuxProcess_ { #endif char* cgroup; unsigned int oom; - char* ttyDevice; #ifdef HAVE_DELAYACCT unsigned long long int delay_read_time; unsigned long long cpu_delay_total; diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index e51c33ea..4564f8e6 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -1196,7 +1196,7 @@ static bool LinuxProcessList_readCmdlineFile(Process* process, openat_arg_t proc return true; } -static char* LinuxProcessList_updateTtyDevice(TtyDriver* ttyDrivers, unsigned int tty_nr) { +static char* LinuxProcessList_updateTtyDevice(TtyDriver* ttyDrivers, unsigned long int tty_nr) { unsigned int maj = major(tty_nr); unsigned int min = minor(tty_nr); @@ -1363,13 +1363,13 @@ static bool LinuxProcessList_recurseProcTree(LinuxProcessList* this, openat_arg_ char command[MAX_NAME + 1]; unsigned long long int lasttimes = (lp->utime + lp->stime); - unsigned int tty_nr = proc->tty_nr; + unsigned long int tty_nr = proc->tty_nr; if (! LinuxProcessList_readStatFile(proc, procFd, command, sizeof(command))) goto errorReadingProcess; if (tty_nr != proc->tty_nr && this->ttyDrivers) { - free(lp->ttyDevice); - lp->ttyDevice = LinuxProcessList_updateTtyDevice(this->ttyDrivers, proc->tty_nr); + free(proc->tty_name); + proc->tty_name = LinuxProcessList_updateTtyDevice(this->ttyDrivers, proc->tty_nr); } if (settings->flags & PROCESS_FLAG_LINUX_IOPRIO) { |