diff options
author | Fabien Thomas <fabient@FreeBSD.org> | 2011-11-01 09:28:47 +0000 |
---|---|---|
committer | Fabien Thomas <fabient@FreeBSD.org> | 2011-11-01 09:28:47 +0000 |
commit | 66ce99369a5c324459d99cdec6539c18a026e315 (patch) | |
tree | 37c3d6a243660f84fae7db891624b70c9449aee2 /usr.sbin/pmcstat | |
parent | 20a5d5dc604e32faeadf7a22c90b10e6f354bd72 (diff) | |
download | src-66ce99369a5c324459d99cdec6539c18a026e315.tar.gz src-66ce99369a5c324459d99cdec6539c18a026e315.zip |
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
Notes
Notes:
svn path=/head/; revision=226986
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 5d9db61952db..45d64ac5800d 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; |