diff options
author | fabient <fabient@FreeBSD.org> | 2011-11-01 09:28:47 +0000 |
---|---|---|
committer | fabient <fabient@FreeBSD.org> | 2011-11-01 09:28:47 +0000 |
commit | 705fefeaf98a849857edd3dc612c34b43d583e8e (patch) | |
tree | 37c3d6a243660f84fae7db891624b70c9449aee2 /usr.sbin/pmcstat | |
parent | 80b1c68a336c2287452d9014dda432ac146311df (diff) | |
download | FreeBSD-src-705fefeaf98a849857edd3dc612c34b43d583e8e.zip FreeBSD-src-705fefeaf98a849857edd3dc612c34b43d583e8e.tar.gz |
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
Diffstat (limited to 'usr.sbin/pmcstat')
-rw-r--r-- | usr.sbin/pmcstat/pmcstat.c | 6 |
1 files changed, 4 insertions, 2 deletions
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; |