summaryrefslogtreecommitdiffstats
path: root/usr.sbin/iostat
diff options
context:
space:
mode:
authorguido <guido@FreeBSD.org>2001-09-26 19:35:03 +0000
committerguido <guido@FreeBSD.org>2001-09-26 19:35:03 +0000
commitf1bb635905c19ef85aaed0a1f2ced18b2b26133e (patch)
tree9da189d5ba4ee50bb629a4be7074e11d501e62cf /usr.sbin/iostat
parent31fb58e79e98c012345053409dd0b1c2f1840f38 (diff)
downloadFreeBSD-src-f1bb635905c19ef85aaed0a1f2ced18b2b26133e.zip
FreeBSD-src-f1bb635905c19ef85aaed0a1f2ced18b2b26133e.tar.gz
Redo patch in 1.22 such that the header printing is reset when the
process gets a SIGCONT Reviewed by: kris@freebs.org MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/iostat')
-rw-r--r--usr.sbin/iostat/iostat.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 672c468..d11909a 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -109,7 +109,6 @@
#include <ctype.h>
#include <fcntl.h>
#include <kvm.h>
-#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -135,13 +134,13 @@ struct statinfo cur, last;
int num_devices;
struct device_selection *dev_select;
int maxshowdevs;
+volatile sig_atomic_t headercount;
int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0;
-volatile sig_atomic_t phdr_flag = 0;
/* local function declarations */
static void usage(void);
-static void phdr(int signo);
-static void do_phdr();
+static void needhdr(int signo);
+static void phdr(void);
static void devstats(int perf_select, long double etime, int havelast);
static void cpustats(void);
static int readvar(kvm_t *kd, const char *name, int nlid, void *ptr,
@@ -173,7 +172,6 @@ main(int argc, char **argv)
int num_matches = 0;
char errbuf[_POSIX2_LINE_MAX];
kvm_t *kd = NULL;
- int headercount;
long generation;
int num_devices_specified;
int num_selected, num_selections;
@@ -419,7 +417,7 @@ main(int argc, char **argv)
* If the user stops the program (control-Z) and then resumes it,
* print out the header again.
*/
- (void)signal(SIGCONT, phdr);
+ (void)signal(SIGCONT, needhdr);
for (headercount = 1;;) {
struct devinfo *tmp_dinfo;
@@ -436,11 +434,6 @@ main(int argc, char **argv)
}
}
- if (phdr_flag) {
- phdr_flag = 0;
- do_phdr();
- }
-
if (Cflag > 0) {
if (readvar(kd, "kern.cp_time", X_CP_TIME,
&cur.cp_time, sizeof(cur.cp_time)) != 0) {
@@ -450,7 +443,7 @@ main(int argc, char **argv)
}
if (!--headercount) {
- do_phdr();
+ phdr();
headercount = 20;
}
@@ -492,7 +485,7 @@ main(int argc, char **argv)
errx(1, "%s", devstat_errbuf);
break;
case 1:
- do_phdr();
+ phdr();
headercount = 20;
break;
default:
@@ -527,7 +520,7 @@ main(int argc, char **argv)
errx(1,"%s", devstat_errbuf);
break;
case 1:
- do_phdr();
+ phdr();
headercount = 20;
break;
default:
@@ -577,15 +570,18 @@ main(int argc, char **argv)
exit(0);
}
-static void
-phdr(int signo)
+/*
+ * Force a header to be prepended to the next output.
+ */
+void
+needhdr(int signo)
{
-
- phdr_flag = 1;
+
+ headercount = 1;
}
static void
-do_phdr()
+phdr(void)
{
register int i;
int printed;
@@ -637,6 +633,7 @@ do_phdr()
(void)printf(" us ni sy in id\n");
else
printf("\n");
+
}
static void
OpenPOWER on IntegriCloud