summaryrefslogtreecommitdiff
path: root/bin/ps
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2001-12-05 02:24:00 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2001-12-05 02:24:00 +0000
commit475d20ecf5b0f9ebec712884801e0325923e0f25 (patch)
tree0cc6b7dcddbb34fd65ee9a1146a2c26f22779cee /bin/ps
parent0a638c3831b9e2840012e3a9176fcfb29226d3b7 (diff)
Get MAXSLP from kvm/sysctl. It's patchable in the kernel now.
Diffstat (limited to 'bin/ps')
-rw-r--r--bin/ps/extern.h4
-rw-r--r--bin/ps/nlist.c20
-rw-r--r--bin/ps/print.c6
3 files changed, 22 insertions, 8 deletions
diff --git a/bin/ps/extern.h b/bin/ps/extern.h
index a8f87664c6b..428381e3030 100644
--- a/bin/ps/extern.h
+++ b/bin/ps/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.5 1997/09/03 13:51:39 kstailey Exp $ */
+/* $OpenBSD: extern.h,v 1.6 2001/12/05 02:23:59 art Exp $ */
/* $NetBSD: extern.h,v 1.10 1995/05/21 13:38:27 mycroft Exp $ */
/*-
@@ -42,7 +42,7 @@ struct var;
struct varent;
extern fixpt_t ccpu;
-extern int eval, fscale, mempages, nlistread, rawcpu;
+extern int eval, fscale, mempages, nlistread, rawcpu, maxslp;
extern int sumrusage, termwidth, totwidth;
extern VAR var[];
extern VARENT *vhead;
diff --git a/bin/ps/nlist.c b/bin/ps/nlist.c
index c9a1086181b..9c74980b9f1 100644
--- a/bin/ps/nlist.c
+++ b/bin/ps/nlist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nlist.c,v 1.7 2001/06/03 04:18:22 angelos Exp $ */
+/* $OpenBSD: nlist.c,v 1.8 2001/12/05 02:23:59 art Exp $ */
/* $NetBSD: nlist.c,v 1.11 1995/03/21 09:08:03 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: nlist.c,v 1.7 2001/06/03 04:18:22 angelos Exp $";
+static char rcsid[] = "$OpenBSD: nlist.c,v 1.8 2001/12/05 02:23:59 art Exp $";
#endif
#endif /* not lint */
@@ -65,6 +65,8 @@ struct nlist psnl[] = {
#define X_CCPU 1
{"_physmem"},
#define X_PHYSMEM 2
+ {"_maxslp"},
+#define X_MAXSLP 3
{NULL}
};
@@ -72,6 +74,7 @@ fixpt_t ccpu; /* kernel _ccpu variable */
int nlistread; /* if nlist already read. */
int mempages; /* number of pages of phys. memory */
int fscale; /* kernel _fscale variable */
+int maxslp;
extern kvm_t *kd;
@@ -105,6 +108,10 @@ donlist()
warnx("ccpu: %s", kvm_geterr(kd));
eval = rval = 1;
}
+ if (kread(X_MAXSLP, maxslp)) {
+ warnx("maxslp: %s", kvm_geterr(kd));
+ eval = rval = 1;
+ }
}
else {
siz = sizeof (fscale);
@@ -125,7 +132,14 @@ donlist()
mib[0] = CTL_KERN;
mib[1] = KERN_CCPU;
if (sysctl(mib, 2, &ccpu, &siz, NULL, 0) < 0) {
- warnx("avail_ccpu: failed to get kern.ccpu");
+ warnx("ccpu: failed to get kern.ccpu");
+ eval = rval = 1;
+ }
+ siz = sizeof (maxslp);
+ mib[0] = CTL_VM;
+ mib[1] = VM_MAXSLP;
+ if (sysctl(mib, 2, &maxslp, &siz, NULL, 0) < 0) {
+ warnx("maxslp: failed to get vm.maxslp");
eval = rval = 1;
}
}
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 9e0096595e2..a52d9ebdeb8 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: print.c,v 1.21 2001/12/01 19:01:45 deraadt Exp $ */
+/* $OpenBSD: print.c,v 1.22 2001/12/05 02:23:59 art Exp $ */
/* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
-static char rcsid[] = "$OpenBSD: print.c,v 1.21 2001/12/01 19:01:45 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: print.c,v 1.22 2001/12/05 02:23:59 art Exp $";
#endif
#endif /* not lint */
@@ -211,7 +211,7 @@ state(k, ve)
case SSLEEP:
if (flag & P_SINTR) /* interruptible (long) */
- *cp = p->p_slptime >= MAXSLP ? 'I' : 'S';
+ *cp = p->p_slptime >= maxslp ? 'I' : 'S';
else
*cp = 'D';
break;