From 705fefeaf98a849857edd3dc612c34b43d583e8e Mon Sep 17 00:00:00 2001 From: fabient Date: Tue, 1 Nov 2011 09:28:47 +0000 Subject: Two bugs fixed: - Do not close stdout or stderr when redirecting to file. - Correctly handle error code to detect when no buffer available. MFC after: 1 month --- usr.sbin/pmcstat/pmcstat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr.sbin/pmcstat') diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c index 5d9db61..45d64ac 100644 --- a/usr.sbin/pmcstat/pmcstat.c +++ b/usr.sbin/pmcstat/pmcstat.c @@ -796,7 +796,9 @@ main(int argc, char **argv) break; case 'o': /* outputfile */ - if (args.pa_printfile != NULL) + if (args.pa_printfile != NULL && + args.pa_printfile != stdout && + args.pa_printfile != stderr) (void) fclose(args.pa_printfile); if ((args.pa_printfile = fopen(optarg, "w")) == NULL) errx(EX_OSERR, "ERROR: cannot open \"%s\" for " @@ -1394,7 +1396,7 @@ main(int argc, char **argv) case EVFILT_TIMER: /* print out counting PMCs */ if ((args.pa_flags & FLAG_DO_TOP) && - pmc_flush_logfile() != ENOBUFS) + pmc_flush_logfile() == 0) do_read = 1; do_print = 1; break; -- cgit v1.1