Don't do unsafe activities in the syscall handler.
MFC after: 2 weeks
This commit is contained in:
parent
ffacb1a399
commit
e65cded7f3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=82723
@ -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:
|
||||
@ -571,6 +579,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
|
||||
|
Loading…
Reference in New Issue
Block a user