From 17d77f8016fdba663bec885b93f275431576bbc9 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Mon, 7 Sep 2015 00:00:00 -0500 Subject: [PATCH] library: add PROCPS_PIDS_TTY_NAME to compliment number OK, ok, this was kind of a huge omission. So please do not select the TTY field for display in top quite yet, at least until a next patch has been pushed to GitLab. And to produce a correct sort order for this new field the GNU 'strverscmp' routine was a necessary addition. Signed-off-by: Jim Warner --- proc/pids.c | 14 ++++++++++++-- proc/pids.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/proc/pids.c b/proc/pids.c index ff66cede..091c2c18 100644 --- a/proc/pids.c +++ b/proc/pids.c @@ -38,8 +38,9 @@ #include #include "procps-private.h" -#include "readproc.h" // and two headers for bridged -#include "wchan.h" // support (temporary include) +#include "devname.h" // and a few headers for our +#include "readproc.h" // bridged libprocps support +#include "wchan.h" // ( maybe just temporary? ) //#define UNREF_RPTHASH // report on hashing, at uref time //#define FPRINT_STACKS // enable validate_stacks output @@ -210,6 +211,7 @@ REG_set(TICS_USER, ull_int, utime) REG_set(TICS_USER_C, ull_int, cutime) REG_set(TIME_START, ull_int, start_time) REG_set(TTY, s_int, tty) +setDECL(TTY_NAME) { char buf[64]; (void)I; dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV); R->result.str = strdup(buf); } REG_set(VM_DATA, ul_int, vm_data) REG_set(VM_EXE, ul_int, vm_exe) REG_set(VM_LIB, ul_int, vm_lib) @@ -297,6 +299,13 @@ static int srtNAME(strv) ( return P->order * strcoll((*b->result.strv), (*a->result.strv)); } +static int srtNAME(strvers) ( + const struct pids_stack **A, const struct pids_stack **B, struct sort_parms *P) { + const struct pids_result *a = (*A)->head + P->offset; + const struct pids_result *b = (*B)->head + P->offset; + return P->order * strverscmp(b->result.str, a->result.str); +} + static int srtNAME(noop) ( const struct pids_stack **A, const struct pids_stack **B, enum pids_item *O) { (void)A; (void)B; (void)O; @@ -450,6 +459,7 @@ static struct { { RS(TICS_USER_C), f_stat, NULL, QS(ull_int), 0 }, { RS(TIME_START), f_stat, NULL, QS(ull_int), 0 }, { RS(TTY), f_stat, NULL, QS(s_int), 0 }, + { RS(TTY_NAME), f_stat, FF(str), QS(strvers), 0 }, { RS(VM_DATA), f_status, NULL, QS(ul_int), 0 }, { RS(VM_EXE), f_status, NULL, QS(ul_int), 0 }, { RS(VM_LIB), f_status, NULL, QS(ul_int), 0 }, diff --git a/proc/pids.h b/proc/pids.h index 68d9ddcd..6b5fa76d 100644 --- a/proc/pids.h +++ b/proc/pids.h @@ -122,6 +122,7 @@ enum pids_item { PROCPS_PIDS_TICS_USER_C, // ull_int PROCPS_PIDS_TIME_START, // ull_int PROCPS_PIDS_TTY, // s_int + PROCPS_PIDS_TTY_NAME, // str PROCPS_PIDS_VM_DATA, // ul_int PROCPS_PIDS_VM_EXE, // ul_int PROCPS_PIDS_VM_LIB, // ul_int -- 2.40.0