diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2021-01-27 15:11:42 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2021-01-30 14:21:26 +0100 |
commit | a3c8285237c673189b28c897910cf6eb8629bfaf (patch) | |
tree | 1ba239046f4b8707a9eec2b1a2b8ccd86bac8945 /Process.c | |
parent | 03d6345c891b93b4658481f891fa2af5ce1c951b (diff) |
Refactor to tty_nr process field display
If no terminal name can be found, fall back to generic display method
with major and minor device numbers.
Print special value '(none)' in case both are zero.
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -365,7 +365,17 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field case TIME: Process_printTime(str, this->time); return; case TGID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->tgid); break; case TPGID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->tpgid); break; - case TTY_NR: xSnprintf(buffer, n, "%3u:%3u ", major(this->tty_nr), minor(this->tty_nr)); break; + case TTY_NR: { + unsigned int major = major(this->tty_nr); + unsigned int minor = minor(this->tty_nr); + if (major == 0 && minor == 0) { + attr = CRT_colors[PROCESS_SHADOW]; + xSnprintf(buffer, n, "(none) "); + } else { + xSnprintf(buffer, n, "%3u:%3u ", major, minor); + } + break; + } case USER: { if (Process_getuid != this->st_uid) attr = CRT_colors[PROCESS_SHADOW]; |