summaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorEric Jackson <ericj@cvs.openbsd.org>2001-05-04 16:48:35 +0000
committerEric Jackson <ericj@cvs.openbsd.org>2001-05-04 16:48:35 +0000
commitf6b8662814e0d3fe23e02d640a681f53abbf73ab (patch)
treec06ca258f64dc26295b17a235b324f643032b662 /usr.bin/systat
parent743a607bb5558bf1596fa7730eff3fd0c1bc0389 (diff)
handle kvm_nlist() failing, from pr#1798.
Patch similar to the one submitted by <peterw@documenta.com.au>
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/main.c14
-rw-r--r--usr.bin/systat/mbufs.c12
-rw-r--r--usr.bin/systat/netstat.c12
-rw-r--r--usr.bin/systat/pigs.c11
-rw-r--r--usr.bin/systat/vmstat.c12
5 files changed, 34 insertions, 27 deletions
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index bc2f89a3733..0698929dc1c 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.14 1997/11/04 12:20:19 kstailey Exp $ */
+/* $OpenBSD: main.c,v 1.15 2001/05/04 16:48:34 ericj Exp $ */
/* $NetBSD: main.c,v 1.8 1996/05/10 23:16:36 thorpej Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: main.c,v 1.14 1997/11/04 12:20:19 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.15 2001/05/04 16:48:34 ericj Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -96,7 +96,7 @@ main(argc, argv)
int argc;
char **argv;
{
- int ch;
+ int ch, ret;
char errbuf[_POSIX2_LINE_MAX];
while ((ch = getopt(argc, argv, "M:N:w:")) != -1)
@@ -148,10 +148,12 @@ main(argc, argv)
error("%s", errbuf);
exit(1);
}
- if (kvm_nlist(kd, namelist)) {
+
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- exit(1);
- }
+
if (namelist[X_FIRST].n_type == 0)
errx(1, "couldn't read namelist");
signal(SIGINT, die);
diff --git a/usr.bin/systat/mbufs.c b/usr.bin/systat/mbufs.c
index 72c13e09d8e..397b3f7f7cd 100644
--- a/usr.bin/systat/mbufs.c
+++ b/usr.bin/systat/mbufs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbufs.c,v 1.4 1997/12/19 09:03:32 deraadt Exp $ */
+/* $OpenBSD: mbufs.c,v 1.5 2001/05/04 16:48:34 ericj Exp $ */
/* $NetBSD: mbufs.c,v 1.2 1995/01/20 08:52:02 jtc Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)mbufs.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: mbufs.c,v 1.4 1997/12/19 09:03:32 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: mbufs.c,v 1.5 2001/05/04 16:48:34 ericj Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -145,11 +145,13 @@ static struct nlist namelist[] = {
int
initmbufs()
{
+ int ret;
+
if (namelist[X_MBSTAT].n_type == 0) {
- if (kvm_nlist(kd, namelist)) {
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- return(0);
- }
if (namelist[X_MBSTAT].n_type == 0) {
error("namelist on %s failed", _PATH_UNIX);
return(0);
diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c
index 1226c632018..67115a0590a 100644
--- a/usr.bin/systat/netstat.c
+++ b/usr.bin/systat/netstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.c,v 1.13 2000/05/24 13:17:08 itojun Exp $ */
+/* $OpenBSD: netstat.c,v 1.14 2001/05/04 16:48:34 ericj Exp $ */
/* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93";
#endif
-static char rcsid[] = "$OpenBSD: netstat.c,v 1.13 2000/05/24 13:17:08 itojun Exp $";
+static char rcsid[] = "$OpenBSD: netstat.c,v 1.14 2001/05/04 16:48:34 ericj Exp $";
#endif /* not lint */
/*
@@ -162,10 +162,12 @@ static struct nlist namelist[] = {
int
initnetstat()
{
- if (kvm_nlist(kd, namelist)) {
+ int ret;
+
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- return(0);
- }
if (namelist[X_TCBTABLE].n_value == 0) {
error("No symbols in namelist");
return(0);
diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c
index 163dbef4efa..7c61dcda310 100644
--- a/usr.bin/systat/pigs.c
+++ b/usr.bin/systat/pigs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pigs.c,v 1.6 2000/06/18 17:59:55 niklas Exp $ */
+/* $OpenBSD: pigs.c,v 1.7 2001/05/04 16:48:34 ericj Exp $ */
/* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)pigs.c 8.2 (Berkeley) 9/23/93";
#endif
-static char rcsid[] = "$OpenBSD: pigs.c,v 1.6 2000/06/18 17:59:55 niklas Exp $";
+static char rcsid[] = "$OpenBSD: pigs.c,v 1.7 2001/05/04 16:48:34 ericj Exp $";
#endif /* not lint */
/*
@@ -157,12 +157,13 @@ int
initpigs()
{
fixpt_t ccpu;
+ int ret;
if (namelist[X_FIRST].n_type == 0) {
- if (kvm_nlist(kd, namelist)) {
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- return(0);
- }
if (namelist[X_FIRST].n_type == 0) {
error("namelist failed");
return(0);
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index b550e469c0a..cf4e5204a8a 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmstat.c,v 1.21 2000/02/22 21:24:02 deraadt Exp $ */
+/* $OpenBSD: vmstat.c,v 1.22 2001/05/04 16:48:34 ericj Exp $ */
/* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
-static char rcsid[] = "$OpenBSD: vmstat.c,v 1.21 2000/02/22 21:24:02 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: vmstat.c,v 1.22 2001/05/04 16:48:34 ericj Exp $";
#endif /* not lint */
/*
@@ -212,14 +212,14 @@ int
initkre()
{
char *intrnamebuf, *cp;
- int i;
+ int i, ret;
static int once = 0;
if (namelist[0].n_type == 0) {
- if (kvm_nlist(kd, namelist)) {
+ if ((ret = kvm_nlist(kd, namelist)) == -1)
+ errx(1, "%s", kvm_geterr(kd));
+ else if (ret)
nlisterr(namelist);
- return(0);
- }
if (namelist[0].n_type == 0) {
error("No namelist");
return(0);