summaryrefslogtreecommitdiffstats
path: root/usr.sbin/iostat
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2001-09-01 07:40:19 +0000
committerkris <kris@FreeBSD.org>2001-09-01 07:40:19 +0000
commit5c1ab9470b6ae0c03d07552589cc5b3866f3e9ff (patch)
treef10721ad7bbc73868f497bdc18517427fde1d272 /usr.sbin/iostat
parent70a0876b07ed186b07aca40d1bd573ee4ee9c191 (diff)
downloadFreeBSD-src-5c1ab9470b6ae0c03d07552589cc5b3866f3e9ff.zip
FreeBSD-src-5c1ab9470b6ae0c03d07552589cc5b3866f3e9ff.tar.gz
Don't do unsafe activities in the syscall handler.
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/iostat')
-rw-r--r--usr.sbin/iostat/iostat.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 3611968..672c468 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -109,6 +109,7 @@
#include <ctype.h>
#include <fcntl.h>
#include <kvm.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -135,10 +136,12 @@ int num_devices;
struct device_selection *dev_select;
int maxshowdevs;
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 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,
@@ -433,6 +436,11 @@ 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) {
@@ -442,7 +450,7 @@ main(int argc, char **argv)
}
if (!--headercount) {
- phdr(0);
+ do_phdr();
headercount = 20;
}
@@ -484,7 +492,7 @@ main(int argc, char **argv)
errx(1, "%s", devstat_errbuf);
break;
case 1:
- phdr(0);
+ do_phdr();
headercount = 20;
break;
default:
@@ -519,7 +527,7 @@ main(int argc, char **argv)
errx(1,"%s", devstat_errbuf);
break;
case 1:
- phdr(0);
+ do_phdr();
headercount = 20;
break;
default:
@@ -572,6 +580,13 @@ main(int argc, char **argv)
static void
phdr(int signo)
{
+
+ phdr_flag = 1;
+}
+
+static void
+do_phdr()
+{
register int i;
int printed;
@@ -622,7 +637,6 @@ phdr(int signo)
(void)printf(" us ni sy in id\n");
else
printf("\n");
-
}
static void
OpenPOWER on IntegriCloud