Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/ps Add support for printing wide sigset_t properly.



details:   https://anonhg.NetBSD.org/src/rev/fade6e91146a
branches:  trunk
changeset: 471962:fade6e91146a
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 16 13:34:32 1999 +0000

description:
Add support for printing wide sigset_t properly.

diffstat:

 bin/ps/keyword.c |  19 +++++++++++++------
 bin/ps/print.c   |  25 +++++++++++++++++++++++--
 bin/ps/ps.h      |   4 ++--
 3 files changed, 38 insertions(+), 10 deletions(-)

diffs (118 lines):

diff -r 1fd7ac4ccf7d -r fade6e91146a bin/ps/keyword.c
--- a/bin/ps/keyword.c  Fri Apr 16 13:31:40 1999 +0000
+++ b/bin/ps/keyword.c  Fri Apr 16 13:34:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: keyword.c,v 1.17 1998/02/17 21:37:56 thorpej Exp $     */
+/*     $NetBSD: keyword.c,v 1.18 1999/04/16 13:34:32 christos Exp $    */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)keyword.c  8.5 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: keyword.c,v 1.17 1998/02/17 21:37:56 thorpej Exp $");
+__RCSID("$NetBSD: keyword.c,v 1.18 1999/04/16 13:34:32 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -55,12 +55,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <signal.h>
 
 #include "ps.h"
 
 static VAR *findvar __P((char *));
 static int  vcmp __P((const void *, const void *));
 
+
+#define SIGWIDTH       (((_NSIG / 32) + 1) * 8)
+
 #ifdef NOTINUSE
 int    utime(), stime(), ixrss(), idrss(), isrss();
        {{"utime"}, "UTIME", USER, utime, 4},
@@ -151,11 +155,14 @@
        {"ruser", "RUSER", NULL, LJUST, runame, USERLEN},
        {"sess", "SESS", NULL, 0, evar, 6, EOFF(e_sess), KPTR, "x"},
        PID("sid", "SID", evar, EOFF(e_sid)),
-       {"sig", "PENDING", NULL, 0, pvar, 8, POFF(p_siglist), INT, "x"},
-       {"sigcatch", "CAUGHT", NULL, 0, pvar, 8, POFF(p_sigcatch), UINT, "x"},
+       {"sig", "PENDING",
+           NULL, 0, pvar, SIGWIDTH, POFF(p_siglist), SIGLIST, "s"},
+       {"sigcatch", "CAUGHT",
+           NULL, 0, pvar, SIGWIDTH, POFF(p_sigcatch), SIGLIST, "s"},
        {"sigignore", "IGNORED",
-               NULL, 0, pvar, 8, POFF(p_sigignore), UINT, "x"},
-       {"sigmask", "BLOCKED", NULL, 0, pvar, 8, POFF(p_sigmask), UINT, "x"},
+           NULL, 0, pvar, SIGWIDTH, POFF(p_sigignore), SIGLIST, "s"},
+       {"sigmask", "BLOCKED",
+           NULL, 0, pvar, SIGWIDTH, POFF(p_sigmask), SIGLIST, "s"},
        {"sl", "SL", NULL, INF127, pvar, 3, POFF(p_slptime), UINT, "d"},
        {"start", "STARTED", NULL, LJUST|USER, started, 8},
        {"stat", "", "state"},
diff -r 1fd7ac4ccf7d -r fade6e91146a bin/ps/print.c
--- a/bin/ps/print.c    Fri Apr 16 13:31:40 1999 +0000
+++ b/bin/ps/print.c    Fri Apr 16 13:34:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print.c,v 1.39 1998/07/28 18:41:59 mycroft Exp $       */
+/*     $NetBSD: print.c,v 1.40 1999/04/16 13:34:32 christos Exp $      */
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)print.c    8.6 (Berkeley) 4/16/94";
 #else
-__RCSID("$NetBSD: print.c,v 1.39 1998/07/28 18:41:59 mycroft Exp $");
+__RCSID("$NetBSD: print.c,v 1.40 1999/04/16 13:34:32 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -724,6 +724,27 @@
        case KPTR:
                (void)printf(ofmt, v->width, GET(u_long));
                break;
+       case SIGLIST:
+               {
+                       sigset_t *s = (sigset_t *)(void *)bp;
+                       size_t i;
+#define SIGSETSIZE     (sizeof(s->__bits) / sizeof(s->__bits[0]))
+                       char buf[SIGSETSIZE * 8 + 1];
+
+                       for (i = 0; i < SIGSETSIZE; i++)
+                               (void)snprintf(&buf[i * 8], 9, "%.8x",
+                                   s->__bits[(SIGSETSIZE - 1) - i]);
+
+                       /* Skip leading zeroes */
+                       for (i = 0; buf[i]; i++)
+                               if (buf[i] != '0')
+                                       break;
+
+                       if (buf[i] == '\0')
+                               i--;
+                       (void)printf(ofmt, v->width, &buf[i]);
+               }
+               break;
        default:
                errx(1, "unknown type %d", v->type);
        }
diff -r 1fd7ac4ccf7d -r fade6e91146a bin/ps/ps.h
--- a/bin/ps/ps.h       Fri Apr 16 13:31:40 1999 +0000
+++ b/bin/ps/ps.h       Fri Apr 16 13:34:32 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ps.h,v 1.12 1996/10/02 18:07:27 ws Exp $       */
+/*     $NetBSD: ps.h,v 1.13 1999/04/16 13:34:32 christos Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
 #define        UNLIMITED       0       /* unlimited terminal width */
 enum type {
        CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR,
-       INT32, UINT32
+       INT32, UINT32, SIGLIST
 };
 
 struct usave {



Home | Main Index | Thread Index | Old Index