]> granicus.if.org Git - procps-ng/commitdiff
library: add abbreviated TTY_NUMBER to that <pids> API
authorJim Warner <james.warner@comcast.net>
Wed, 30 Sep 2015 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Mon, 5 Oct 2015 10:39:37 +0000 (21:39 +1100)
While not documented in the man page, ps allows 'tty4'
as a valid output specifier complimenting 'tty8' & its
derivatives. So, in order to eliminate a dev_to_name()
call in the ps program the library will now offer this
abbreviated tty version (consisting of a number only).

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/pids.c
proc/pids.h

index be96ec844f03dee85ed677754a2a02026227b9e1..9d0a802118abef8d9ef87d9bad39d2ec1cb34235 100644 (file)
@@ -210,6 +210,7 @@ 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); }
+setDECL(TTY_NUMBER)   { char buf[64]; (void)I; dev_to_tty(buf, sizeof(buf), P->tty, P->tid, ABBREV_DEV|ABBREV_TTY|ABBREV_PTS); 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)
@@ -456,6 +457,7 @@ static struct {
     { 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(TTY_NUMBER),        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       },
index dc9ee6b5057ab24aeeea9623e907813db8b7c4ee..55be7f836976aa9222e4ef74bdd96c7ca30be725 100644 (file)
@@ -123,6 +123,7 @@ enum pids_item {
     PROCPS_PIDS_TIME_START,            // ull_int
     PROCPS_PIDS_TTY,                   // s_int
     PROCPS_PIDS_TTY_NAME,              // str
+    PROCPS_PIDS_TTY_NUMBER,            // str
     PROCPS_PIDS_VM_DATA,               // ul_int
     PROCPS_PIDS_VM_EXE,                // ul_int
     PROCPS_PIDS_VM_LIB,                // ul_int