ps: implement -o sid
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 29 Jul 2017 00:20:17 +0000 (02:20 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 29 Jul 2017 00:20:17 +0000 (02:20 +0200)
function                                             old     new   delta
func_sid                                               -      29     +29
out_spec                                             320     340     +20
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 49/0)               Total: 49 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
procps/ps.c

index d4d787d78c047a212d34aa11dbf6d2dafc5e706e..6348df5f236d5641da9e3441286f79c3a3ca9566 100644 (file)
@@ -340,6 +340,11 @@ static void func_pgid(char *buf, int size, const procps_status_t *ps)
        sprintf(buf, "%*u", size, ps->pgid);
 }
 
+static void func_sid(char *buf, int size, const procps_status_t *ps)
+{
+       sprintf(buf, "%*u", size, ps->sid);
+}
+
 static void put_lu(char *buf, int size, unsigned long u)
 {
        char buf4[5];
@@ -458,6 +463,7 @@ static const ps_out_t out_spec[] = {
        { 6                  , "tty"   ,"TT"     ,func_tty   ,PSSCAN_TTY     },
        { 4                  , "vsz"   ,"VSZ"    ,func_vsz   ,PSSCAN_VSZ     },
 /* Not mandated, but useful: */
+       { 5                  , "sid"   ,"SID"    ,func_sid   ,PSSCAN_SID     },
        { 4                  , "stat"  ,"STAT"   ,func_state ,PSSCAN_STATE   },
        { 4                  , "rss"   ,"RSS"    ,func_rss   ,PSSCAN_RSS     },
 #if ENABLE_SELINUX