summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pmcstat/pmcstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pmcstat/pmcstat.c')
-rw-r--r--usr.sbin/pmcstat/pmcstat.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index 31ef877..5d9db61 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -552,7 +552,7 @@ main(int argc, char **argv)
int hcpu, option, npmc, ncpu;
int c, check_driver_stats, current_cpu, current_sampling_count;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
- int do_print;
+ int do_print, do_read;
size_t dummy;
int graphdepth;
int pipefd[2], rfd;
@@ -1328,7 +1328,7 @@ main(int argc, char **argv)
* are killed by a SIGINT.
*/
runstate = PMCSTAT_RUNNING;
- do_print = 0;
+ do_print = do_read = 0;
do {
if ((c = kevent(pmcstat_kq, NULL, 0, &kev, 1, NULL)) <= 0) {
if (errno != EINTR)
@@ -1351,8 +1351,10 @@ main(int argc, char **argv)
(args.pa_flags & FLAG_DO_TOP)) {
if (pmcstat_keypress_log())
runstate = pmcstat_close_log();
- } else
+ } else {
+ do_read = 0;
runstate = pmcstat_process_log();
+ }
break;
case EVFILT_SIGNAL:
@@ -1377,9 +1379,6 @@ main(int argc, char **argv)
/* Kill the child process if we started it */
if (args.pa_flags & FLAG_HAS_COMMANDLINE)
pmcstat_kill_process();
- /* Close the pipe to self, if present. */
- if (args.pa_flags & FLAG_HAS_PIPE)
- (void) close(pipefd[READPIPEFD]);
runstate = pmcstat_close_log();
} else if (kev.ident == SIGWINCH) {
if (ioctl(fileno(args.pa_printfile),
@@ -1394,12 +1393,15 @@ main(int argc, char **argv)
break;
case EVFILT_TIMER: /* print out counting PMCs */
+ if ((args.pa_flags & FLAG_DO_TOP) &&
+ pmc_flush_logfile() != ENOBUFS)
+ do_read = 1;
do_print = 1;
break;
}
- if (do_print) {
+ if (do_print && !do_read) {
if ((args.pa_required & FLAG_HAS_OUTPUT_LOGFILE) == 0) {
pmcstat_print_pmcs();
if (runstate == PMCSTAT_FINISHED && /* final newline */
@@ -1420,7 +1422,7 @@ main(int argc, char **argv)
/* flush any pending log entries */
if (args.pa_flags & (FLAG_HAS_OUTPUT_LOGFILE | FLAG_HAS_PIPE))
- pmc_flush_logfile();
+ pmc_close_logfile();
pmcstat_cleanup();
OpenPOWER on IntegriCloud