Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Nov 2011 09:28:48 +0000 (UTC)
From:      Fabien Thomas <fabient@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r226986 - head/usr.sbin/pmcstat
Message-ID:  <201111010928.pA19SmSP058457@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: fabient
Date: Tue Nov  1 09:28:47 2011
New Revision: 226986
URL: http://svn.freebsd.org/changeset/base/226986

Log:
  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

Modified:
  head/usr.sbin/pmcstat/pmcstat.c

Modified: head/usr.sbin/pmcstat/pmcstat.c
==============================================================================
--- head/usr.sbin/pmcstat/pmcstat.c	Tue Nov  1 08:57:49 2011	(r226985)
+++ head/usr.sbin/pmcstat/pmcstat.c	Tue Nov  1 09:28:47 2011	(r226986)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201111010928.pA19SmSP058457>